183
rated 0 times
[
184]
[
1]
/ answers: 1 / hits: 29559
/ 13 Years ago, thu, september 22, 2011, 12:00:00
My view is set up as below. simple.
var ItemView = Backbone.View.extend({
tagName : li,
events : {
click : display
},
display : function() {
//app.navigate('item'); // take me to my route!
}
});
And I have my router
var App = Backbone.Router.extend({
routes: {
: index,
item : view_item
},
index: function() {
alert('hi!');
},
view_item: function() {
alert('bye!');
}
});
app = new App();
Backbone.history.start();
Now, when I click on ItemView, it should run display method and I want the display method to take me to the route I specified in routes item.
Is this possible? I thought navigate function will work, but it doesn't. How could I achieve this?
More From » backbone.js