Juan Jardim
Juan Jardim

Reputation: 2252

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

Upvotes: 6

Views: 3782

Answers (2)

Billybonks
Billybonks

Reputation: 1568

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.

Upvotes: 9

user3560658
user3560658

Reputation: 93

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')

Upvotes: 5

Related Questions