I dig a little deeper into my first functional application and should better understand what is going on in my controller.
Here I have a controller that processes the action when the user clicks "Option". Looking at the this object, several questions arise:
- What is
this ? I expect this to be an instance of my Option model, but it lacks some properties (for example, "identity: 'model: Option"). - If
this is an instance of my Option model, why is the 'model' property undefined? Why doesn't he know that? - What is
this.content ? It looks like some things are inside content ( id and isSuppressed ) and some are not ( this.isSelected ) - why is this?
Disclaimer Although there has not been any presentation problems so far, there may be errors in my ember application architecture.
Screen Debugging Controller: 
Optional model and controller
App.Option = Ember.Object.extend({ identity: 'model: Option', id: '', cost: '', isSelected: false, isSuppressed: false }); App.OptionController = Ember.Controller.extend({ actions: { toggleOption: function() { this.set('isSelected', !this.get('isSelected')); var id = this.get('content.id'); this.send('deselect', this.get('content.id')); } } }); App.OptionsController = Ember.ArrayController.extend({ actions: { deselect: function(exception) { var opts = this.rejectBy('id', exception) opts.setEach('isSuppressed', true); } } });
source share