Hi, First of all I’m relatively new to Ember and I don’t know if what I’m trying is even possible, so feel free to tell me if there is other way.
Right now I have a Page model like this:
BackApp.Page = DS.Model.extend({
name: DS.attr('string'),
title: DS.attr('string'),
url: DS.attr('string'),
createdAt: DS.attr('date'),
modules: DS.hasMany('modules', {inverse: 'page', polymorphic: true, async: true})
});
Which has many modules of different type (I’m only showing these for brevity):
BackApp.Module = DS.Model.extend({
name: DS.attr('string'),
type: DS.attr('string'),
page: DS.belongsTo('page', {inverse: 'modules'})
});
BackApp.ClaimsModule = BackApp.Module.extend({
title: DS.attr('string'),
text: DS.attr('string'),
other: DS.attr('string')
});
BackApp.BasicModule = BackApp.Module.extend({
title: DS.attr('string'),
text: DS.attr('string'),
moreStuff: DS.attr('string')
});
What I am trying to accomplish is, on the edit page route, to render views to be able to manipulate the modules directly (each module of different type should render a different type of view). Right now, I’m trying to make this with a CollectionView, but I’m not having any luck so far:
Inside the page.edit template I have:
{{render 'modules' modules }}
I have a ‘modules’ controller:
BackApp.ModulesController = Ember.ArrayController.extend({
// Implement your controller here.
init: function(){
console.log('init modules controller');
},
lookupItemController: function( object ) {
console.log('in lookup init controller');
}
});
And a ModulesView:
BackApp.ModulesView = Ember.CollectionView.extend({
init: function(){
console.log('init modules view');
},
createChildView: function(viewClass, attrs) {
return this._super(BackApp.ModuleView, attrs);
}
});
I tried to debug whether the createChildView from the ModulesView or the lookupItemController from the ModulesController were triggered, but neither was, so I guess I’m messing it up with the render itself.
Thank you in advance.