Reputation: 1491
I am probably missing something easy or doing something wrong, but I am trying this and can't get it to fire the function...
var Home = Backbone.View.extend({
indexAction: function() {
console.log('index');
},
render: function() {
console.log('render');
}
});
Home.indexAction();
All I get is this error:
Uncaught TypeError: Object function (){return i.apply(this,arguments)} has no method 'indexAction'
Upvotes: 1
Views: 41
Reputation: 33544
You created the view type but did not create an instance.
You need to instantiate a view of type Home
now:
var h = new Home();
h.indexAction();
Also, it might be better to rename Home as HomeView
, so you know it's a view which can be instantiated.
var HomeView = Backbone.View.extend({
indexAction: function() {
console.log('index');
},
render: function() {
console.log('render');
}
});
var home = new HomeView();
Upvotes: 3