0
我有一個控制器,我開始我的木偶應用程序並定義一個主要區域。在我的主區域內,有一個mainLayout進一步包含兩個子區域,我正在渲染這兩個子區域,但onShow/onRender函數不會被調用。 :Marionette Layout的onShow功能沒有被調用
var eventController = my.class{
create: function(){
//This is the model
var mainModel = new model();
this.createEventApp = new Backbone.Marionette.Application();
this.createEventApp.addRegions({
//This is the main container
mainRegion: ".event-container"
});
this.createEventApp.addInitializer(function(options){
var self=this;
//This is the main Item View for the app
new EventView({
model: mainModel,
region: self.mainRegion
});
});
this.createEventApp.start();
}
}
現在我相應的項目來查看這個應用程序是這樣的:
var eventView = Backbone.Marionette.ItemView.extend{
//Template for the item view
template: eventViewTemplate;
initialize: function(options){
_.bindAll(this);
this.model = options.model;
this.region = options.region;
//Creating a main layout inside mainRegion of the app
var myLayout = Backbone.Marionette.Layout.extend({
template: EventViewTemplate,
regions: {
//Region 1
//Region 2
}
});
this.mainLayout = new myLayout();
this.region.show(this.mainLayout);
this.region1view = new region1({
model: this.model
});
//same for region 2
//showing both the regions in the layout
this.mainLayout.region1.show(this.region1view);
this.mainLayout.region2.show(this.region2view);
},
onShow: function(){
//I want to do something here but this function doesn't event gets called
}
}