azicchetti / jquerymobile-router

A router/controller for jquery mobile. Also adds support for client-side parameters in the hash part of the url. The routes handles regexp based routes. This plugin can be used alone or (better) with Backbone.js or Spine.js, because it's originally meant to replace their router with something integrated with jQM.
GNU General Public License v2.0
402 stars 69 forks source link

defaultHandler is not invoked when customer handlers are not specified #90

Open AlexBulankou opened 8 years ago

AlexBulankou commented 8 years ago

If I configure my router like this (no specific handlers, but I would like defaultHandler to fire)

var router=new $.mobile.Router({            
        },{ 
        },{ 
          defaultHandler: function(type, ui, page) {
            console.log("Default handler called due to unknown route (" 
              + type + ", " + ui + ", " + page + ")"
            );
          },
          defaultHandlerEvents: "bc,c,i,bs,s,bh,h",
      defaultArgsRe: true
        });

defaultHandler is not invoked. But it is invoked when I specify at least one route:

var router=new $.mobile.Router({   
              "#index": { handler: function(type){
            console.log("Index has been "+(type=="pagehide"?"hidden":"shown"));
          }, events: "h,s" }    
        },{
        },{ 
          defaultHandler: function(type, ui, page) {
            console.log("Default handler called due to unknown route (" 
              + type + ", " + ui + ", " + page + ")"
            );
          },
          defaultHandlerEvents: "bc,c,i,bs,s,bh,h",
      defaultArgsRe: true
        });

Expected: defaultHandler to be invoked even without specific routes specified. I read through the introduction page, don't think this is intended behavior.