changePage stops working after JS error in show event #5249

Closed
bittlelum opened this Issue Nov 5, 2012 · 3 comments

Comments

Projects
None yet
4 participants
@bittlelum

I've run into an issue where changePage stops working when the new page throws an exception in a "show" event handler. It seems that, since that exception is uncaught, it errors out the changePage method, and so isPageTransitioning never gets unset. As a result, future calls to changePage never actually run, they just push onto the transition queue and return, so navigation is disabled without any indication of a problem (apart from an error in the console).

The problem is with this line, in transitionPages(), line 508 of jquery.mobile.navigation.js in 1.2:

toPage.data( "page" )._trigger( "show", null, { prevPage: fromPage || $( "" ) } );

(incidentally, I suspect the same would happen in the fromPage's "hide" event above that, although I haven't tested that).

I'm using 1.1.1, but it seems to still be present in 1.2.

@gabrielschulhof

This comment has been minimized.

Show comment
Hide comment
@gabrielschulhof

gabrielschulhof Nov 28, 2012

Contributor

Well, adding a try block around these lines (and it's not just the "show", but also the "hide" of the previous page) is not a good idea, because these errors need to be propagated all the way to the console, otherwise you will never know that they have occurred.

Nevertheless, the navigation should be robust enough to continue despite them.

Contributor

gabrielschulhof commented Nov 28, 2012

Well, adding a try block around these lines (and it's not just the "show", but also the "hide" of the previous page) is not a good idea, because these errors need to be propagated all the way to the console, otherwise you will never know that they have occurred.

Nevertheless, the navigation should be robust enough to continue despite them.

@jerone

This comment has been minimized.

Show comment
Hide comment
@jerone

jerone Nov 29, 2012

Contributor

I agree with @gabrielschulhof. These errors should be shown in the console. I had a similar issue with the same line in jquery.mobile.js. A listitem with link and then overruling the click to open a page. I forgot to cancel the original event.

listitem.on("vclick", function (e) {
    var href = $(this).find("a").attr("href");
    if (href) {
        $.mobile.changePage(href);
    }
});

I changed it to:

listitem.on("vclick click", function (e) {
    var href = $(this).find("a").attr("href");
    if (href) {
        $.mobile.changePage(href);

        // prevent slower event (click);
        return false;
    }
});
Contributor

jerone commented Nov 29, 2012

I agree with @gabrielschulhof. These errors should be shown in the console. I had a similar issue with the same line in jquery.mobile.js. A listitem with link and then overruling the click to open a page. I forgot to cancel the original event.

listitem.on("vclick", function (e) {
    var href = $(this).find("a").attr("href");
    if (href) {
        $.mobile.changePage(href);
    }
});

I changed it to:

listitem.on("vclick click", function (e) {
    var href = $(this).find("a").attr("href");
    if (href) {
        $.mobile.changePage(href);

        // prevent slower event (click);
        return false;
    }
});
@arschmitz

This comment has been minimized.

Show comment
Hide comment
@arschmitz

arschmitz Oct 24, 2014

Member

Im closing this as stale

Member

arschmitz commented Oct 24, 2014

Im closing this as stale

@arschmitz arschmitz closed this Oct 24, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment