Permalink
Browse files

Call init when both mobileinit and domready have happened instead of …

…just domready.

Fixes #4136
  • Loading branch information...
gseguin committed May 16, 2012
1 parent 8f4f809 commit 8b938e2e357c696b09ed7b4690e185e7951c1d25
Showing with 13 additions and 2 deletions.
  1. +13 −2 js/jquery.mobile.navigation.pushstate.js
@@ -12,7 +12,17 @@ define( [ "jquery", "./jquery.mobile.navigation", "../external/requirejs/depend!
var pushStateHandler = {},
self = pushStateHandler,
$win = $( window ),
url = $.mobile.path.parseUrl( location.href );
url = $.mobile.path.parseUrl( location.href ),
mobileinitDeferred = $.Deferred(),
domreadyDeferred = $.Deferred();
$( document ).ready( function() {
domreadyDeferred.resolve();
});
$( document ).one( "mobileinit", function() {
mobileinitDeferred.resolve();
});
$.extend( pushStateHandler, {
// TODO move to a path helper, this is rather common functionality
@@ -138,7 +148,8 @@ define( [ "jquery", "./jquery.mobile.navigation", "../external/requirejs/depend!
}
});
$( function() {
// We need to init when both "mobileinit" and "domready" have happened
$.when( domreadyDeferred, mobileinitDeferred ).done( function() {
if( $.mobile.pushStateEnabled && $.support.pushState ){
pushStateHandler.init();
}

3 comments on commit 8b938e2

@johnbender

This comment has been minimized.

Show comment
Hide comment
@johnbender

johnbender May 17, 2012

Contributor

This commit makes me happy. It's super nice.

Contributor

johnbender replied May 17, 2012

This commit makes me happy. It's super nice.

@frequent

This comment has been minimized.

Show comment
Hide comment
@frequent

frequent Jun 28, 2012

Contributor

@johnbender: this saved half my day working with requireJS. I'm still stuck with controlgroups not being initialized on the first page though. I guess this is because the controlgroup widget is triggered from initializePage(), is it?. Any idea for a workaround?

Contributor

frequent replied Jun 28, 2012

@johnbender: this saved half my day working with requireJS. I'm still stuck with controlgroups not being initialized on the first page though. I guess this is because the controlgroup widget is triggered from initializePage(), is it?. Any idea for a workaround?

@frequent

This comment has been minimized.

Show comment
Hide comment
@frequent

frequent Jun 28, 2012

Contributor

@johnbender: never mind - ctrl.controlgroup({ excludeInvisible: false })

Contributor

frequent replied Jun 28, 2012

@johnbender: never mind - ctrl.controlgroup({ excludeInvisible: false })

Please sign in to comment.