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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

handler getting called twice even when step "url" selected

chapak0 opened this issue · comments

This is what my router looks like:

var katanarouter = new $.mobile.Router([
{"#home" : {handler: "findstorestart", events: "bs", argsre: true}},
{"#carmake" : {handler: "carmake", events: "bC", argsre: true, step: "url"}}
],

    {
        home : function(eventType, matchObj, ui, page, event) {
            // code here
            console.log("findstorestart handler");
        },  
        carmake : function(eventType, matchObj, ui, page, event) {
            // code here
            event.preventDefault();
            console.log("carmake handler");
            setTimeout(function(){
                getMakes(ui);   
            },600);

        }
    });

getmakes calls a webservice and returns data but the service gets called twice. Is there a known bug, or it's meant to work like this?

Uhm, with step=url the handler should be called just once.

Your code is very similar to the test-bC.html example, which seems to work well with jQM 1.3.x and with the new 1.4 alpha.

Can you please check whether getMakes() invokes ui.bCDeferred.resolve() to perform the page transition instead of calling $.mobile.changePage ?