【发布时间】:2017-10-18 18:44:29
【问题描述】:
所以我正在学习backbonejs,使用nodecellar-rethinkdb示例作为练习
将 Backbone.js 和 Underscore.js 文件更新到最新版本后,我收到一条错误消息,提示“页面未定义”。相同的代码适用于 Backbone.js 0.9.2。所以我猜有些东西已经被弃用了。
这是给我错误的分页文件的代码:
window.WineListView = Backbone.View.extend({
initialize: function () {
this.render();
},
render: function () {
var wines = this.model.models;
var len = wines.length;
var startPos = (this.options.page - 1) * 8;
var endPos = Math.min(startPos + 8, len);
$(this.el).html('<ul class="thumbnails"></ul>');
for (var i = startPos; i < endPos; i++) {
$('.thumbnails', this.el).append(new WineListItemView({model: wines[i]}).render().el);
}
$(this.el).append(new Paginator({model: this.model, page: this.options.page}).render().el);
return this;
}
});
window.WineListItemView = Backbone.View.extend({
tagName: "li",
initialize: function () {
this.model.bind("change", this.render, this);
this.model.bind("destroy", this.close, this);
},
render: function () {
$(this.el).html(this.template(this.model.toJSON()));
return this;
}
});
能否请您告诉我代码无法与最新版本一起使用的原因,并修复它以与最新的主干.js 一起使用
提前致谢。
【问题讨论】:
标签: javascript jquery backbone.js pagination