I can't get an observer to actually do anything in Ember.js. Basically, I have a Ember.Select dropdown menu, and want to bind some more action to the event of selecting the value in the dropdown. For example:
App.selectedPersonController = Ember.Object.create({
person: null,
personDidChange: function() {
// do something here when the person changes
console.log("PERSON CHANGED")
}.observes('person')
});
And nothing is happening, even though the 'person' attribute is getting updated. Any suggestions?
This is due to the fact that as of version pre4 you cannot set a property or observable upon the Em.*.create() function. You have to first use the .extend() function first and set all your properties and observables in that, then create that object.
As an example, take a look at this jsfiddle that is working with the extend functionality. Then try to take it away by using only create and you'll see that the app no longer works.
Or use createWithMixins() instead of create()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With