我想知道如何當輸入被集中觸發一個動作..
現在我使用這個對我的模板:{{view "clickinput" class="form-control" placeholder="search..." value=s action="focus"}}
並將此作爲的觀點:如何在輸入獲得焦點時觸發動作?
export default Ember.TextField.extend({
onEvent: 'focusIn',
focusIn: function() {
this.sendAction('focusIn', this, event);
}
});
,這對我的控制器:
actions: {
focus: function() {
alert('f');
}
}
,但它不工作..
我得到的鉻此錯誤:Uncaught Error: Assertion Failed: The focusIn action was triggered on the component <[email protected]: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.
爲什麼?