azicchetti/jquerymobile-router

Can we initialize a empty router

satyasuman opened this issue · 1 comments

Hi is it possible to initialize an empty router and then add routes to it?

Hi,
yes, you can setup an empty router, then add your routes at a later time.

Just invoke the add() method of the router instance:

myrouter.add({
        "#something": "bsHandler",
        "#otherone": { events: "s,h", handler: "bsHandler2" }
}, handlerObj);

The array syntax is also supported (and preferred):

myrouter.add([
        { "#something": "handler" },
        { "#otherone": { events: "s,h", handler: "handler2" } }
], handlerObj);

Cheers,
Andrea