Supervisor not working in Amber?

I cannot get an observer to actually do anything in Ember.js. Basically, I have an Ember.Select drop-down menu, and you want to associate another action with a value selection event in the drop-down list. For instance:

App.selectedPersonController = Ember.Object.create({ person: null, personDidChange: function() { // do something here when the person changes console.log("PERSON CHANGED") }.observes('person') }); 

And nothing happens even if the "person" attribute is updated. Any suggestions?

+2
source share
2 answers

This is because, since pre4, you cannot set a property or observe the Em.*.create() function. First you must first use the .extend() function and set all your properties and observable objects in it, and then create this object.

As an example, consider this jsfiddle , which works with advanced functionality. Then try deleting it using only create and you will see that the application no longer works.

+6
source

Or use createWithMixins () instead of create ()

+3
source

Source: https://habr.com/ru/post/943848/


All Articles