Addy OsmaniによるBackbone.jsアプリケーションの開発を学んでいて、行き詰まっています。
これが私の見解です:
var TodoView = Backbone.View.extend({
tagName: 'li',
className: 'todo_list',
todoTpl: _.template($('#item-template').html()),
events:{
'dblclick label': 'edit',
'keypress .edit':'updateOnEnter',
'blur .edit':'closed'
},
initialize:function(){
_.bindAll(this, 'edit','render','updateOnEnter','closed');
this.render();
},
render: function(){
this.$el.html(this.todoTpl(this.model.toJSON()));
this.input = this.$('.edit');
return this;
},
edit: function(){},
updateOnEnter: function(){},
closed: function(e){}
});
var todoView = new TodoView();
console.log(todoView.el);
そしてここに私のエラーがあります:
TypeError: this.model is undefined
this.$el.html(this.todoTpl(this.model.toJSON()));
私はどこが間違っていますか?