您好,我的模板中有以下代码:
<div {{action "play" this target="view"}}>{{title}}</div>
以及我认为的以下代码:
MB3.PlaylistView = Ember.View.extend({
play: function(event) {
}
});
传递给播放函数的参数事件现在是播放列表模型(在上面显示的操作助手中作为“this”传递)
在 Ember-pre2 中,传递给操作处理程序的参数接收到浏览器事件,其中包含 currentTarget
等属性以及模型所在的属性上下文。
如何在 ember-pre4 中访问原生事件的参数,如 currentTarget
?
最佳答案
这张票也有很多讨论:
https://github.com/emberjs/ember.js/issues/1684
推荐的解决方案是创建自定义 View ,然后定义点击处理程序。单击处理程序将事件作为第一个参数传递。
MB3.PlayButtonView = Em.View.extend({
click: function(event){
... click handler
}
});
关于ember.js - ember-pre4 Action 助手不再传递浏览器事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14709694/