【发布时间】:2016-09-30 04:46:51
【问题描述】:
我正在尝试创建自定义输入组件。 首先,我尝试使用本机输入组件。像这样的
<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 观察者被触发但焦点事件不监听,否则按键被触发。
如何同时使用两种方式绑定和焦点事件?
【问题讨论】: