TAGS :Viewed: 3 - Published at: a few seconds ago

[ property name trimmed in '.observes()' ]

Here is an example of very strange behavior: http://jsfiddle.net/H1D_/RsqxR/ Is it a bug or I'm doing it wrong?

With following code in controller:

App.ApplicationController =  Em.ObjectController.extend({
    obj_reflector: (function(){        
        this.set('obj',App[this.get('obj_type')].createRecord());
    }).observes('obj_type')
});

I got this error in console right after app initialized:

Object in path obj_typ could not be found or was destroyed.

Answer 1


The error is raised due to the selectionBinding you gave to Ember.Select... The ApplicationController didn't owe any property "obj_type" either as its property or in its content...

 App.ApplicationController =  Em.ObjectController.extend({
   obj_type: '',
   obj_reflector: (function(){        
  // Not aware what are you trying with createRecord();
  //        this.set('obj',App[this.get('obj_type')].createRecord());
  }).observes('obj_type')
});

Your working fiddle is here