有人对为什么在模型上执行 .set 时这个该死的视图不会更新有任何想法吗?我认为如果可能与我放入的渲染功能有关......
骨干视图:
App.Views.PanelOne = Backbone.View.extend({
initialize: function() {
console.log("View PanelOne Initialized");
panelonesetting = this.model.get('panel_one');
console.log( panelonesetting );
_.bindAll(this, 'render');
this.model.bind('change', this.render);
},
render: function(){
if ( panelonesetting == "poolprice" ){
this.$el.html(JST['dashboard/poolprice']({}));
return this;
};
if ( panelonesetting == "none" ){
this.$el.html(JST['dashboard/none']({}));
return this;
};
if ( panelonesetting == "noconnection" ){
this.$el.html(JST['dashboard/noconnection']({}));
return this;
};
}
});
骨干路由器:
App.Routers.Dashboard = Backbone.Router.extend({
routes: {
"" : "index"
},
initialize: function(options) {
console.log("Router initialized");
preflist = new App.Models.PrefList({});
preflist.fetch({
success: function() {
console.log( preflist );
paneloneview = new App.Views.PanelOne({ model: preflist });
$('#panelone').html(paneloneview.render().$el);
}
});
},
index: function() {
}
});