更改侦察器的组合框在余烬js

时间:2014-11-24 10:40:34

标签: javascript asp.net-mvc ember.js handlebars.js

使用下面的代码我在ember中显示组合框。

{{view  "select"  content=model    prompt="Please select a name"  selectionBinding="App.selectedComboBoxController.model"  optionValuePath="content.fullName" optionLabelPath="content.title"   }}
  

输出    http://emberjs.jsbin.com/jodaqumoba/1/edit?html,css,js,output

我的要求是组合框更改时间如何在提交功能

下面调用
App.ComboBoxRoute = Ember.Route.extend({

    model: function () {     
          return posts;     
    },
    actions: {
        submit: function () {
           textId = document.getElementById("emnn");
           textId = textId.value;
            alert(textId);
        }
    }

});

1 个答案:

答案 0 :(得分:0)

您可以将观察者添加到组合框值。在观察者中发送一个会使路线起泡的动作。

Here is the working demo.

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);
    }
  }
});