2014-11-24 2 views
0

используя нижеследующий код i show combo box in ember.Combo box on change Listener in Embers js

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

}); 

ответ

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