I have the following code snippet:
App.TripLegView = Em.View.extend({
transportMeanType: null,
transportMeanTypeChanged: function () {
this.carView = App.CarView.create();
var childView = this.createChildView(this.carView );
this.get('childViews').pushObject(childView);
}
}).observes('transportMeanType'),
App.CarView = Em.View.extend();
However when i debug the above code, the child view does not seem to be added to the childViews array.
Can anyone explain how to correctly add child views.
First of all, it seems you are misusing the
observes(), it should be defined on the function.If you want to manipulate childviews, I think you should use Ember.ContainerView
Your code would be like this:
If it doesn’t work, please post a jsfiddle to give an example.