我有从服务器收集数据的主干模型:
Job.Models.Response = Backbone.Model.extend({
defaults: {
'authStatus': false,
'id': '1',
'name': 'name',
},
urlRoot: '/static/js/public/json/'
});
我有 data-id =“来自/static/js/public/json/的id”的按钮。
Job.Views.Response = Backbone.View.extend({
el: '.ra-response-button',
events: {
"click": "load"
},
load: function () {
var info = this.$el.data();
this.model.set({ id: info.id});
this.model.fetch();
if (this.model.attributes.authStatus === false) {
console.log('Register')
}
else {
console.log('Unregister')
}
}
});
如果我在获取后 console.log 我的模型,它不会更新,但数据获取成功。这里会出现什么样的问题?
这里我初始化我们的插件:
var responseModel = new Job.Models.Response;
var response = new Job.Views.Response({ model: responseModel });