Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to fire change event on select emberjs

Tags:

ember.js

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

like image 312
Nadeem Khedr Avatar asked Jun 17 '14 16:06

Nadeem Khedr


1 Answers

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}}
like image 151
Kingpin2k Avatar answered Nov 19 '22 03:11

Kingpin2k