0
我想了解其中this.item
从这个骨干查看未来:this.item中的骨干查看
Backbone.View.extend({
initialize: function() {
var date = new Date();
this.date = date;
this.month = date.getMonth();
this.day = date.getDay();
this.year = date.getFullYear();
this.calendar = new calendar();
_.bindAll(this);
},
showActivityItem: function(e) {
var target = $(e.currentTarget);
var id = target.attr("data-id");
var item = this.item;
}
});
的item
似乎是骨干示范,我确定与除它是如何分配到item
属性的。
当我输出在控制台的项目,我得到:
child {cid: "c85", attributes: Object, _changing: false, _previousAttributes: Object, changed: Object…}
_changing: false
_events: Object
_pending: false
_previousAttributes: Object
attributes: Object
changed: Object
cid: "c85"
collection: child
__proto__: Surrogate
showActivityItem被每个事件称为:
events: {
'click #activityList .boxEntry': 'showActivityItem'
},
有在做这样的类没有代码。 Backbone视图中Backbone模型的item
是一些未公开的访问器吗?它不在Backbone网站上的View属性列表中。
谢谢。
是那个工作代码?没有像item属性那样的东西,所以模型必须在初始化时分配。 – Puigcerber
这只是代码的缩写版本。我已经添加了初始化方法。正如你所看到的,它并没有被分配到那里,因此我对它被分配的方式感到困惑。视图中的任何位置都没有分配。我想它有可能被分配到视图之外。 –
你可以做'console.log(item)'?因为它应该是未定义的... – Puigcerber