正如你所看到的,我在骨干方面很新,我不知道为什么这不起作用???
我收到这个错误?
未捕获的类型错误:无法调用未定义的“on”方法
代码
TodoItem = Backbone.Model.extend({});
TodoList = Backbone.Collection.extend({
model: TodoItem,
url: "todo"
});
var TodoView = Backbone.View.extend({
el: '#content',
initialize: function() {
this.model.bind('change', this.render, this);
},
render: function(model) {
this.$el.html('test');
}
});
$(function() {
var todoList = new TodoList();
todoList.fetch();
new TodoView();
});
URL TODO - JSON
[ {description: 'Pick up milk.', status: 'incomplete', id: 1},
{description: '去洗车', status: 'incomplete', id: 2} ]