Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger an action when an input gets focus?

I want to know how to trigger an action when an input gets focused..
right now I'm using this on my template: {{view "clickinput" class="form-control" placeholder="search..." value=s action="focus"}}
and this as the view:

export default Ember.TextField.extend({
  onEvent: 'focusIn',
  focusIn: function() {
    this.sendAction('focusIn', this, event);
  }
});

and this on my controller:

actions: {
  focus: function() {
    alert('f');
  }
}

but it doesn't work..
I get this error on chrome: Uncaught Error: Assertion Failed: The focusIn action was triggered on the component <appkit@view:clickinput::ember438>, but the action name (function superWrapper() { var ret, sup = this.__nextSuper; this.__nextSuper = superFunc; ret = func.apply(this, arguments); this.__nextSuper = sup; return ret; }) was not a string.

why?

like image 382
iguider Avatar asked Apr 16 '14 18:04

iguider


1 Answers

It turned out to be simpler than I thought..
I just had to write {{input class="form-control" placeholder="search..." value=s focus-in="focus"}} in my template

like image 133
iguider Avatar answered Nov 16 '22 00:11

iguider