Permalink
Browse files

Add a last-resort fallback to ensure content is accessible if somethi…

…ng goes wrong during enhancements, such as a runtime error. Fixes #3648
  • Loading branch information...
1 parent 494c5ce commit 818c2f219ef1bff97f4596aaf6c005fd8f7a2b44 scottjehl committed Feb 27, 2012
Showing with 11 additions and 2 deletions.
  1. +11 −2 js/jquery.mobile.init.js
View
@@ -26,8 +26,12 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
$.mobile.ajaxEnabled = false;
}
- // add mobile, initial load "rendering" classes to docEl
+ // Add mobile, initial load "rendering" classes to docEl
$html.addClass( "ui-mobile ui-mobile-rendering" );
+
+ // This is a fallback. If anything goes wrong (JS errors, etc), or events don't fire,
+ // this ensures the rendering class is removed after 5 seconds, so content is visible and accessible
+ setTimeout( hideRenderingClass, 5000 );
// loading div which appears during Ajax requests
// will not appear if $.mobile.loadingMessage is false
@@ -55,6 +59,11 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
}
}
+ //remove initial build class (only present on first pageshow)
+ function hideRenderingClass(){
+ $html.removeClass( "ui-mobile-rendering" );
+ }
+
$.extend($.mobile, {
// turn on/off page loading message.
@@ -124,7 +133,7 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
$.mobile.showPageLoadingMsg();
//remove initial build class (only present on first pageshow)
- $html.removeClass( "ui-mobile-rendering" );
+ hideRenderingClass();
// if hashchange listening is disabled or there's no hash deeplink, change to the first page in the DOM
if ( !$.mobile.hashListeningEnabled || !$.mobile.path.stripHash( location.hash ) ) {

0 comments on commit 818c2f2

Please sign in to comment.