Mat*_*ero 1 javascript css jquery ember.js cordova
我对Ember很新,但这个看起来很奇怪.
我在模板上有一个div看起来像这样:
<div {{action "selectItem" item target="controllers.items"}}> Hello there! </div>
在我的控制器上,我有一个简单的动作回调:
WebComponent.ItemController = Ember.ArrayController.extend(Ember.Evented, {
needs: ["settings"],
actions: {
selectItem: function (item) {
//This here won't fire unless I attach it to a <button> not a <div>
},
refreshList: function () {
//blah
},
...
}
},
Run Code Online (Sandbox Code Playgroud)
......} ......
在完整的披露中,我正在使用模拟器在Phonegap中工作.有任何想法甚至指示在哪里进行这项调查?
我解决了这个问题.看起来Ember没有将点击事件转换为自动触摸事件(Ember 1.8),因为div,span,li等标签似乎对按钮这样的标签这样做.因此,解决方案是添加一个属性以将事件映射到操作.在您的操作中使用on属性.
<div {{action "selectItem" item on="touchEnd" target="controllers.items"}}> Hello there! </div>
Run Code Online (Sandbox Code Playgroud)