我有一个包含页面上的几个子视图的Homeview,当我使用路由器导航到另一个页面时,如何清理现有视图并为我想导航到的页面构建新视图?骨干JS:如何清理导航到另一个网址时的意见?
此应用没有模型/集合,只是视图。
谢谢!代码的
部分:
Home = Backbone.View.extend({
template: "static/js/templates/home.html",
initialize: function() {
_.bindAll(this);
this.render();
},
render: function() {
var view = this;
// Fetch the template, render it to the View element and call done.
namespace.fetchTemplate(this.template, function(tmpl) {
view.el.innerHTML=tmpl();
view.subRender();
});
return this;
},
subRender: function() {
var view = this;
var videoView = new Subview1({
el: $('#wrapper1'),
homeView: view
});
var timeView = new Subview2({
el: $("#wrapper2")
});
}
});
听起来更好的解决方案。 – user469652 2012-04-04 14:35:32