Emberjs - 获取元素的属性点击

Fos*_*tah 3 ember.js

问题:点击后,我看到evt.target.attributes存储了数组中的所有属性.是否有一种更简单的方法,而不必迭代所有属性来获得某个属性值?在这个例子中,我需要点击元素的'note'属性的值.

模板:

<a note="C" {{action "play" on="click"}}>></a>
Run Code Online (Sandbox Code Playgroud)

点击处理程序(播放):

var keys = Ember.View.create({
    templateName: 'keys',
    notes: this.get('allKeys'),
    play:function(evt){
        var attributes= evt.target.attributes;
        console.log(attributes);
    }
Run Code Online (Sandbox Code Playgroud)

Pas*_*ion 6

如果控制器没有支持视图,一种解决方案是将事件目标转换为jQuery对象

play : function(event) {
    var note = $(event.target).attr("note");
    // More code here
}
Run Code Online (Sandbox Code Playgroud)