6

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

Juan Jardim
  • 2,232
  • 6
  • 28
  • 46
  • 2
    You could follow the same pattern put forth in this question http://stackoverflow.com/questions/24154974/trigger-an-action-on-the-change-event-with-ember-js-checkbox-input-helper/24155149#24155149 – Kingpin2k Aug 25 '14 at 16:51

2 Answers2

9

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.

poweratom
  • 2,270
  • 23
  • 25
Billybonks
  • 1,568
  • 3
  • 15
  • 32
5

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

user3560658
  • 93
  • 2
  • 4