javascript - Backbone pushState routes -


I want to change the hashtag on beautiful urls to deal with backlone.js pushstate. Using the localhost and the path to my script is http: //localhost/test/backbone/test.html . But every time the click is thrown at me localhost / login what am I doing?

  var AppRouter = backbone.rotter.ex ({route: {"login": "getPost", "* actions": "defaultRoute"}}); Var app_router = new appraiser; App_router.on ('Route: Receive Post', Function (ID) {Alerts ("Login");}); App_router.on ('route: defaultRoute', function (verb) {alert (verb);}); App_router.navigate ("/ login", {trigger: true}); Backbone.history.start ({PushState: true, root: '/ login /'});    

You need to add:

  $ (Document)) .delegate ("a", "click", function (evt) {var href = $ (this) .attr ("href"); var protocol = this.protocol + "//"; if (href .slice (Protocol.length)! == Protocol & Protocol! == 'javascript: //' & amp; amp; amp; amp; href.substring (0, 1)! == '#') {evt. PreventDefault (); Backbone History.navigate (href, true);}});   

and the last 2 strings should be:

  ap_outer. Navigate ("/ login", {trigger: true}); // & lt; - Remove this string backbone.info.start ({PushState: true, root: "test / backbone / test.html"});    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -