Navigating back is broken with autoInitializePage = false (Cannot call method 'trigger' of undefined) #5284

Closed
rbu opened this Issue Nov 14, 2012 · 7 comments

Projects

None yet

5 participants

@rbu
rbu commented Nov 14, 2012

When navigating away from a jQueryMobile application and then back creates an exception when that application has set $.mobile.autoInitializePage = false and calls $.mobile.initializePage() by itself.

Steps to reproduce:

  1. Open http://jsbin.com/ukewu3/279
  2. Click any link inside the page (e.g. jsFiddle)
  3. Use browser's back button
  4. Open JS console

Expected result:
See meaningless debug output

Actual result:
Uncaught TypeError: Cannot call method 'trigger' of undefined

This stems from the fact that $.mobile.pageContainer is undefined before initializePage

@rbu
rbu commented Nov 14, 2012

We're currently using the following monkey-patch for this:

// Monkey patch for jQM bug
// https://github.com/jquery/jquery-mobile/issues/5284
$.mobile._handleHashChange = (function(old) {
    return function() {
        if (undefined === $.mobile.pageContainer) {
            return;
        }
        return old.apply(this, arguments);
    };
}($.mobile._handleHashChange));
@iMoses
iMoses commented Mar 5, 2013

I've been experiencing the exact same problem

@hgross
hgross commented Mar 20, 2013

+1 - Any news on this?

@johnbender johnbender was assigned Apr 4, 2013
@johnbender
Contributor

Switching to the unminified latest I see an issue with the loader widget not with trigger. Still it's clearly not working.

I'll take a look today and hopefully we can work out something sane and quick for the first patch release.

@johnbender
Contributor

The broader issue is that the popstate binding is firing "too early" when returning to the page. I'm going to have to work on this one for a bit.

@rbu

That fits with your hack since you're just killing the navigation when the pageContainer hasn't been created.

@johnbender
Contributor

@rbu @hgross @uGoMobi

There's a fundamental issue with delaying the page initialization and supporting popstate. The popstate that's fired when returning from an external URL contains information about how the page should be initialized, so delaying the initialization means we need to store that info until it happens.

More soon.

@imran1231

Getting same issue on JQUERY Mobile 1.4.0

@johnbender johnbender was unassigned by rbu Mar 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment