Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#16082 closed enhancement (fixed)

dojo/router: add the concept of a default route

Reported by: ben hockey Owned by: Brian Arnold
Priority: undecided Milestone: 1.9
Component: Core Version: 1.8.0
Keywords: Cc:
Blocked By: Blocking:


when starting the router, i believe a typical use case is to honor any existing route but fallback to a default if no route was present when starting.

to do this with dojo/router as it is currently, it's not quite as elegant as it could be if it was something included as part of the router.

one approach as it is currently is this:

        var currentPage = '';

        // register a route
        router.register(/^(.*)$/, function (e) {
                currentPage = e.currentPath;

                // do some stuff

        // start the router

        // if there was no route already set on the page, then go home
        if (!currentPage) {

to make it more elegant maybe the default route could be passed to the router via startup? (open to alternatives)

        // register a route
        router.register(/^(.*)$/, function (e) {
                // do some stuff

        // start the router - default is 'home'

Change History (4)

comment:1 Changed 9 years ago by ben hockey

Owner: set to Brian Arnold
Status: newassigned

comment:2 Changed 8 years ago by Kenneth G. Franqueiro

+1... just thought the same exact thing after using router for the first time today. Any chance this could be done for 1.9?

comment:3 Changed 8 years ago by Brian Arnold

Resolution: fixed
Status: assignedclosed

In [31141]:

Adds concept of default route, fixes #16082

comment:4 Changed 8 years ago by bill

Milestone: tbd1.9
Note: See TracTickets for help on using tickets.