New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
irnc opened this Issue Apr 20, 2012 · 8 comments

Comments

Projects
None yet
4 participants
@irnc
Contributor

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.

@johnbender

This comment has been minimized.

Show comment
Hide comment
@johnbender

johnbender Apr 20, 2012

Contributor

@irnc

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( ["jquery.mobile"] );
  });
});
Contributor

johnbender commented Apr 20, 2012

@irnc

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( ["jquery.mobile"] );
  });
});
@johnbender

This comment has been minimized.

Show comment
Hide comment
@johnbender

johnbender Apr 20, 2012

Contributor

@gseguin

Maybe you can comment?

Contributor

johnbender commented Apr 20, 2012

@gseguin

Maybe you can comment?

@gseguin

This comment has been minimized.

Show comment
Hide comment
@gseguin

gseguin Apr 20, 2012

Member

What @johnbender mentioned should work or even simpler:

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

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

Member

gseguin commented Apr 20, 2012

What @johnbender mentioned should work or even simpler:

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

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

@johnbender

This comment has been minimized.

Show comment
Hide comment
@johnbender

johnbender Apr 20, 2012

Contributor

@gseguin

That's a much better idea 👍

Contributor

johnbender commented Apr 20, 2012

@gseguin

That's a much better idea 👍

@toddparker

This comment has been minimized.

Show comment
Hide comment
@toddparker

toddparker Apr 20, 2012

Contributor

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

Contributor

toddparker commented Apr 20, 2012

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

@toddparker toddparker closed this Apr 20, 2012

@irnc

This comment has been minimized.

Show comment
Hide comment
@irnc

irnc Apr 21, 2012

Contributor

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

See https://github.com/jquery/jquery-mobile/blob/master/js/jquery.mobile.navigation.pushstate.js#L155, maybe this initialization can be done on mibileinit event and not on document.ready?

Contributor

irnc commented Apr 21, 2012

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

See https://github.com/jquery/jquery-mobile/blob/master/js/jquery.mobile.navigation.pushstate.js#L155, maybe this initialization can be done on mibileinit event and not on document.ready?

@johnbender

This comment has been minimized.

Show comment
Hide comment
@johnbender

johnbender Apr 21, 2012

Contributor

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

Contributor

johnbender commented Apr 21, 2012

@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

This comment has been minimized.

Show comment
Hide comment
@gseguin

gseguin May 16, 2012

Member

Should be fixed by 8b938e2

Member

gseguin commented May 16, 2012

Should be fixed by 8b938e2

@toddparker toddparker closed this May 17, 2012

johnbender pushed a commit to johnbender/jquery-mobile that referenced this issue May 22, 2012

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