Can't get trunk routes without hashes?

I want to have bookmark URLs that the browser can capture and process. If I just use Backbone.history.start () , then I can use a hash URL like / # accounts .

But I want a URL without hashes, a la / accounts . But I can't get this to work using Backbone.history.start ({pushState: true}) ( as described by others) . My routes are simple and taken directly from the documentation .

     MyRouter = Backbone.Router.extend ({
         routes: {
             '/ accounts': 'accounts',
         }
     });

I use Chrome (also tried with FF), and the behavior is that the / accounts request goes directly to the server. Backbone is not intercepted at first. Has anyone come across this? How can I get a hash without handling URLs using Backbone?

Thank you in advance

+7
javascript backbone-events
Nov 26 2018-11-11T00:
source share
1 answer

You can navigate to this URL using js using router.navigate( "/accounts", true ) , and not by links or by entering the URL yourself. To use links, you must bind the click event to them and prevent the default action and trigger a transition to href links.

router is an instance of router

+17
Nov 26 2018-11-11T00:
source share



All Articles