var BooksView = Backbone.View.extend({
initialize: function() {
this.render();
},
render: function() {
alert(this.myVar);
}
});
和我的路由器:
var BookRouter = Backbone.Router.extend({
routes: {
'': 'index',
'list/:id': 'list'
},
index: function(){
var booksView = new BooksView({
el: ".content",
myVar: "Example 1"
});
},
list: function(id){
var booksView = new BooksView({
el: ".content",
myVar: "Example 2"
});
}
});
如何访问的变量? this.myVar似乎并不奏效,尽管变量被设置在同一类中?