Ember.Select中的绑定动作

Jua*_*dim 6 javascript jquery handlebars.js ember.js

我想知道如何绑定Ember中的动作.选择só当用户更改类别时我可以执行其他操作:

{{view Ember.Select class="form-control" id="PackCategory"
            content=Categories
            optionValuePath="content.categoryId"
            optionLabelPath="content.name"
            value=VendingAdminController.selectedPack.categoryId}}
Run Code Online (Sandbox Code Playgroud)

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

谢谢

Bil*_*nks 9

像主销建议,

只需在控制器中创建一个函数即可观察到的value属性 {{select}}

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

上面的代码应该放在你的VendingAdminController.


小智 5

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

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