1
我正在尝试创建自定义输入组件。 首先,我尝试使用本机输入组件。像这样的东西EmberJS。如何使用双向绑定进行输入和焦点事件?
<input type="text" value="{{inputValue}}" onblur={{action "toggleInputFocused"}} onfocus={{action "toggleInputFocused"}}>
但是这段代码没有提供双向绑定。观察员的valueChanged不触发
valueChanged: Ember.observer('inputValue', function() {
// deal with the change
this.set("valueSet",(this.get('inputValue').trim().length > 0));
}),
后来我尝试使用输入助手
{{input value=inputValue focus=(action "toggleInputFocused")}}
在这种情况下,观察者的valueChanged被触发,但焦点事件不听,否则按键被触发。
如何一次使用双向绑定和焦点事件?