Can not disable 'push state' plugin when jQM loaded via require.js #4136

irnc opened this Issue Apr 20, 2012 · 8 comments


None yet

4 participants

irnc commented Apr 20, 2012

When jQM are loaded after document ready event, $.mobile.pushStateEnabled option are read before mobileinit event (it is actually read on already fired ready event, i.e. immediately on script execution), thus it is not possible to change it.



This will be low priority since we don't officially support this method of loading jqm. I believe what we've done in the past is to create a meta module where jquery is the initial load dependency, your init methods are in a callback with require of the rest of jqm. Something like:

require( ["jquery"], function(){
  require( ["my-mobile-init-stuff"], function(){
    require( [""] );


Maybe you can comment?

gseguin commented Apr 20, 2012

What @johnbender mentioned should work or even simpler:

require( [ "jquery" ], function( $ ){
  $( window ).one( "mobileinit", function() {
    $.mobile.pushStateEnabled = false;
  require( [ "" ] );

UPDATE: $.one -> $( window ).one



That's a much better idea 👍


Closing this since we don't support it and there is a suggested workaround.

@toddparker toddparker closed this Apr 20, 2012
irnc commented Apr 21, 2012

@gseguin This will not work if require( [ "" ] ); will be called after document.ready because in this case, $.mobile.pushStateEnabled are read immediately upon execution and before mobileinit event.

See, maybe this initialization can be done on mibileinit event and not on document.ready?


@gseguin @irnc

Ah, he's right. The pushStateHandler does it's init on domready instead of page create. I think there's a legit reason for that (ie the initial nav event). Something to think about.

@gseguin gseguin was assigned May 16, 2012
@gseguin gseguin reopened this May 16, 2012
gseguin commented May 16, 2012

Should be fixed by 8b938e2

@toddparker toddparker closed this May 17, 2012
@johnbender johnbender pushed a commit to johnbender/jquery-mobile that referenced this issue May 22, 2012
@gseguin gseguin Call init when both mobileinit and domready have happened instead of …
…just domready.

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