2014-02-05 40 views
2

我有一个自定义的Ember.Select,我重写“改变”事件来处理自己的事件(例如发射一个xhr)如何让给定的行onChange与选择的模型选择

在我的车把文件,我添加了一个选择每行(ArrayController支持)

{{#each thing in controller}} 
{{view App.CustomSelect value=thing.category content=configuration optionValuePath="content.id" optionLabelPath="content.name"}} 
{{/each}} 

在我的javascript我处理该事件,像这样

App.CustomSelect = Ember.Select.extend({ 
    change: function(x) { 
    //in here I can only get the selected option/value 
    //what I really need is both that value (above) 
    //and the model for this given row 
    } 
}); 

我怎样才能绑定到模型具体的选择更改事件?通过我自己的代码

回答

0

来看,得到的模型,你需要做到以下几点:

App.CustomSelect = Ember.Select.extend({ 
    change: function(x) { 
    var selectedModel = this.get('selection'); 
    } 
}); 
+0

时,我的模板控制器是ArrayController这个“选择”是 - 不是的outter模型本身的选项 –