当输入获得焦点时如何触发操作?

2024-01-13

我想知道当输入聚焦时如何触发操作。
现在我在我的模板上使用它:{{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');
  }
}

但它不起作用..
我在 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?


结果比我想象的要简单..
我只需要写{{input class="form-control" placeholder="search..." value=s focus-in="focus"}}在我的模板中

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

当输入获得焦点时如何触发操作? 的相关文章

随机推荐