Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding Action in Ember.Select

I was wondering how to bind an action in an Ember.Select só when the user change the category i could perform other operations:

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

and also how to specify the view as the target?

Thank you

like image 958
Juan Jardim Avatar asked Aug 25 '14 16:08

Juan Jardim


2 Answers

Like kingpin suggested,

Just create a function in your controller that observes the value property of the {{select}}

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

The above code should be placed in your VendingAdminController.

like image 187
Billybonks Avatar answered Oct 23 '22 01:10

Billybonks


I don't have enough rep to comment on the previous answer but I think the ember syntax is observes not observe

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

like image 43
user3560658 Avatar answered Oct 23 '22 01:10

user3560658