Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

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

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

Comments

@rbu
Copy link

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
Copy link
Author

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
Copy link

iMoses commented Mar 5, 2013

I've been experiencing the exact same problem

@hgross
Copy link

hgross commented Mar 20, 2013

+1 - Any news on this?

@ghost ghost assigned johnbender Apr 4, 2013
@johnbender
Copy link
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
Copy link
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
Copy link
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
Copy link

Getting same issue on JQUERY Mobile 1.4.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants