Why is "this" so complicated? Calling Controller "method"


I have a ObjectController with that creates a TREE like structure based on a model (list of EmberData objects) - with a property that observers the model “length” - when the length changes.

When objects get added I need to recreate the tree - but I can not call treeContent

The Ember.run.once function does not call treeContent and can not see it …“this” is not the controller !!

var ScenGrpsController = Ember.ObjectController.extend({ modelDidChange: function(e) { var _self=this; Ember.run.once(_self, “treeContent”); }.observes(‘model.length’),

treeContent: function() {}

I know “this” is a pain but how can I get a ref to the controller I am in ?


Reproduce it with a jsfiddle so we can more easily respond with a solution.

var ScenGrpsController = Ember.ArrayController.extend({
   treeContent: function() {
    // do the tree stuff here

Just do that. That should do it!


Thank you - that solves 1 problem!