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

rbu opened this Issue Nov 14, 2012 · 7 comments


None yet

5 participants

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
  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 commented Nov 14, 2012

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

// Monkey patch for jQM bug
$.mobile._handleHashChange = (function(old) {
    return function() {
        if (undefined === $.mobile.pageContainer) {
        return old.apply(this, arguments);
iMoses commented Mar 5, 2013

I've been experiencing the exact same problem

hgross commented Mar 20, 2013

+1 - Any news on this?

@johnbender johnbender was assigned Apr 4, 2013

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.


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.


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


@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.


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