使用下面的代码,我在ember中显示组合框。
{{view "select" content=model prompt="Please select a name" selectionBinding="App.selectedComboBoxController.model" optionValuePath="content.fullName" optionLabelPath="content.title" }}
我的要求是组合框更改时间如何在提交功能下方调用
App.ComboBoxRoute = Ember.Route.extend({
model: function () {
return posts;
},
actions: {
submit: function () {
textId = document.getElementById("emnn");
textId = textId.value;
alert(textId);
}
}
});
您可以将观察者添加到组合框值。在观察者中发送将使路线冒泡的动作。
App.SelectedComboBoxController = Em.ObjectController.extend({
model:null,
selectionChanged: function() {
this.send('submit', this.get('model'));
}.observes('model')
});
App.IndexRoute = Ember.Route.extend({
model: function() {
return [
{fullName:"the full name1", title:"the title1"},
{fullName:"the full name2", title:"the title2"},
{fullName:"the full name3", title:"the title3"}
];
},
actions: {
submit: function (item) {
alert(item.fullName);
}
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句