Nadeem Khedr
Nadeem Khedr

Reputation: 5313

how to fire change event on select emberjs

The behavior that i want is when changing the select is to save it's model

I though about using observable, but i have another problem

my view looks something like this

{{#each item in model.Items}}
<div class="select">
  {{view Ember.Select 
    content=typesLookup
    selection=type
    prompt="Select Type"
  }}
</div>
{{/each}}

so if i went with the observables solution, what i want is to also know the specific item that has changed to update it

Upvotes: 6

Views: 4503

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

add the observer and selection on an itemController.

App.FooController = Em.ObjectController.extend({
  type:undefined,
  watchType: function(){
    console.log('this model changed', this.get('model'));
  }.observes('type')
});

{{#each item in model.Items itemController='foo'}}
  <div class="select">
    {{view Ember.Select 
      content=typesLookup
      selection=item.type
      prompt="Select Type"
    }}
  </div>
{{/each}}

Upvotes: 7

Related Questions