var BooksView = Backbone.View.extend({
initialize: function() {
this.render();
},
render: function() {
alert(this.myVar);
}
});
and my router:
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"
});
}
});
How do I access the variable? this.myVar doesn't seem to be working, even though the variable is set inside the same class?