我正在玩木偶第一次。 重新呈现ItemViews之后,它们的事件未触发。 简单的例子:重新渲染后的Marionette ItemView事件
App = new Marionette.Application;
App.addRegions({
headerRegion: '#header',
contentRegion: '#content',
});
App.addInitializer(function() {
this.Views = {
MainMenu : new MainMenuView(),
ContentOne : new ContentOneView(),
ContentTwo : new ContentTwoView(),
};
});
App.addInitializer(function() {
var self = this;
var eva = self.vent;
eva.listenTo(self.Views.MainMenu, 'content1', function() {
self.contentRegion.show(self.Views.ContentOne);
});
eva.listenTo(self.Views.MainMenu, 'content2', function() {
self.contentRegion.show(self.Views.ContentTwo);
});
});
App.on('start', function() {
var self = this;
self.contentRegion.show(self.View.ContentOne);
});
App.start();
后重新呈现ContentOneView & ContentTwoView,不会触发他们的活动。 我做错了什么?
我试着使用'self.View.ContentOne.render()''而不是self.contentRegion.show(self.View.ContentOne) ',但没有什么令人开心的。 – iBoozyVoozy
示例:每个ContentView本身都有一个按钮,并且该按钮为事件。第一次所有事件正常触发,但是第二次重新渲染后,按钮事件没有被触发。 – iBoozyVoozy