Ember.Select中的绑定动作

时间:2014-08-25 16:44:01

标签: javascript jquery ember.js handlebars.js

我想知道如何在Ember中选择一个动作。当用户更改类别时我可以执行其他操作:

{{view Ember.Select class="form-control" id="PackCategory"
            content=Categories
            optionValuePath="content.categoryId"
            optionLabelPath="content.name"
            value=VendingAdminController.selectedPack.categoryId}}

以及如何将视图指定为目标?

谢谢

2 个答案:

答案 0 :(得分:9)

像主人建议,

只需在控制器中创建一个观察{{select}}

的value属性的函数
onSelectedPackChange:function(){
  //insert the code that needs to be excuted on change here
}.observes('selectedPack.categoryId')

上述代码应放在VendingAdminController

答案 1 :(得分:5)

我没有足够的代表对前一个答案发表评论,但我认为ember语法是观察不到的

onSelectedPackChange:function(){ //insert the code that needs to be excuted on change here }.observes('selectedPack.categoryId')

相关问题