Backbone.js router does not start when page starts

I have a fairly simple trunk router, and so far everything is working fine. Except when I reload / direct by entering a URL, i.e. http://mydomain.com/#list/50fadc41125b0 I tried almost everything now without any positive results.

myRouter = Backbone.Router.extend({
    routes: {
        "list/:id": "getList",      
        "*actions": "defaultRoute" // not needed right now
    },
    getList: function (id) {
        console.log ("test");
    }
});

I tried it the same way, without any difference

// init router
router = new myRouter;
router.on('route:getList', function (id) {
    [...]
});

I have no idea how to do this! hope someone has an answer for me!

EDIT:

I also start the story

Backbone.history.start();
+5
source share
1 answer

due to an error, I initialized my router asynchronously in a successful fetch statement, so Backbone.history.start()there was nothing to initialize.

Lukas .

+3

All Articles