Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…just domready.

Fixes #4136
  • Loading branch information...
commit 8b938e2e357c696b09ed7b4690e185e7951c1d25 1 parent 8f4f809
@gseguin gseguin authored
Showing with 13 additions and 2 deletions.
  1. +13 −2 js/jquery.mobile.navigation.pushstate.js
View
15 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 commit makes me happy. It's super nice.

@frequent

@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

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

Please sign in to comment.
Something went wrong with that request. Please try again.