Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

setting pushStateEnabled=false when loading jquery/mobile with requireJS is ineffective #4364

Closed
cjolif opened this Issue · 7 comments

4 participants

@cjolif

HTML:

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
    <script data-main="main" src="require-jquery.js"></script>
</head>

main.js:

require(["jquery"], function($) {
    require(["jquery-mobile"], function(){
        $(document).bind("mobileinit", function(){
            $.mobile.hashListeningEnabled = false;
            $.mobile.pushStateEnabled = false;
        });
    });
});

even if pushStateEnabled is set to false push state manage is enabled. You can check that by setting a breakpoint in jQuery mobile pushStateHandler.init method. You will see it is called while it is not if jQuery is not loaded with requireJS. This comes from the fact that in requireJS context this:

    $( function() { 
        if( $.mobile.pushStateEnabled && $.support.pushState ){
            pushStateHandler.init();
        }
    });

is called before mobileinit.

@toddparker

@gseguin - mind weighing in on this one?

@gseguin gseguin was assigned
@gseguin
Collaborator

This is a duplicate of #4136

@gseguin gseguin closed this
@gseguin
Collaborator

@cjolif I believe your main.js should look like that instead:

require( [ "jquery" ], function( $ ) {
    $(document).bind( "mobileinit", function(){
        $.mobile.hashListeningEnabled = false;
        $.mobile.pushStateEnabled = false;
    });

    require( [ "jquery-mobile" ], function(){
         // do cool stuff with jQM
    });
});

But regardless, there is indeed an issue with the way pushState is initialized.

@cjolif

@gseguin right I agree the main.js should be as you suggested, unfortunately it does not work better ;)

@gseguin
Collaborator

@cjolif Can you confirm that 8b938e2 fixes the problem?

@cjolif

this is working perfectly. Thanks!

@pramodD

I also have same issue but $.mobile.pushStateEnabled = false; solve it. Thank you guys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.