How to pass event objects as parameters (from handlebars template to an action in a controller)


#1

Hello,

I am new to ember, thus I would appreciate your assistance. I want to pass an focus-out event (see bold marked text below) from my handlebars template:

{{input type=“text” class=“form-control” focus-out= (action “ccFocusLost” event) }}

To my action in my controller:

   ccFocusLost : function(event) {
    	alert(event.relatedTarget.tagName);
    },

However, i get an undefined when I do as above. I need a way to obtain the focus-out event in order to find out which element will receive the focus after my main element loses it.

Thanks in advance!


#2

Not sure if it helps but I once saw https://github.com/jvanderz22/jvanderz22-ember-typeahead but never used it. It seems to get the event.


#3

Hi Dev,

Not much clear what you want. But, You can try following code to send action

if (event.target === this.get('element')) {
     this.sendAction('YOUR ACTION');
}

OR

Ember.$(event.sender.wrapper).find('PARTCULAR HTML TAG like body, p . . . ')