在当前的应用程序中,我正在使用如下路由器加载我的视图
router('menu/:item', function (item) {
app.uiHandler.toggleMenuSelected('menu', item);
// The below method updates the view with selected menu item's model.
app.channel.publish('menu', item);
});
目前每个菜单项共享相同的数据对象。但是根据每个菜单选择,主视图被替换为新的 html。
我想为每个菜单项提供如下实例
var ractive = new Ractive({
el: 'container', // el is same for all instances.
template: '<p> I am {{selection}}, after {{prevSelection}}!</p>',
data: { selection: 'Home', prevSelection: 'Profile' }
});
但是在这里我的疑问是,每当哈希更改时,我将调用每个实例以将视图呈现为“容器”,如何清除在将主视图替换为新 html 时创建的所有两种方式数据绑定。请帮助我。
如果我以错误的方式处理,那么最好的处理方式是什么。
注意:我的问题可能听起来很愚蠢,但我正在寻找对此的澄清:)