0
votes

For any view in Ember.js we need to create controller with appropriate name in order to use this controller, but this is not a case for views inside ContainerView.

View (inside ContainerView):

App.ChildView = Ember.View.extend({});

Controller:

App.ChildController = Ember.ObjectController.extend({
    init: function () {
        alert('Hell no! I\'m not going to init!');
        return this._super();
    }
});

Above doesn't work...

Solution like this.set('controller', App.ChildController.create()) (inside view) is not an option because Ember.Evented, needs and probably more stuff doesn't work.

Here is the (not) working example: http://jsfiddle.net/wbednarski/XaPSR/

Any help appreciated!

1

1 Answers

1
votes

For any view in Ember.js we need to create controller with appropriate name in order to use this controller

I'm not sure this premise is correct. ContainerView is a pretty low-level view library that does not know anything about controllers. It might be used to create small a widget or component, and in that case the child views would not have their own controllers. If you are looking to bind views inside ContainerView to their own controllers that is a sign that ContainerView is not a good fit for the problem you're trying to solve.

Instead, consider using handlebars helpers like {{render}} and {{each}}.