backbone.js - Backbone router not dispatched? -


i'm new in backbone 0.9.1. found when change hash , can not trigger hash change in demo. url http://[...]/backbone/#help. think should receive alert message "help", i'm not.

$(function() {     var app = {         controllers:{},         initialize: function(){             new app.controllers.routes();             var h = new backbone.history();             h.start({root: '/backbone/'});         }     };      app.controllers.routes = backbone.router.extend({         routes: {             "help":                 "help",             "search/:query":        "search",         },          help: function() {             alert("help");         },          search: function(query) {             alert("search");         }     });      app.initialize(); }); 

is there misunderstanding or misuse?

you don't need instantiate history object yourself. also, if you're not using pushstate, don't need specify root in start options.

so, initialize method should this:

         initialize: function(){             new app.controllers.routes();             backbone.history.start();         } 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -