Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use the first dialog in a document as a page when no pages exist Fixes

  • Loading branch information...
commit 26c1d8e56e4cc692533ba55da9c89548504a8309 1 parent 0f62e96
@johnbender johnbender authored
Showing with 17 additions and 3 deletions.
  1. +17 −3 js/jquery.mobile.init.js
View
20 js/jquery.mobile.init.js
@@ -58,13 +58,27 @@
// find and enhance the pages in the dom and transition to the first page.
initializePage: function() {
// find present pages
- var $pages = $( ":jqmData(role='page')" );
+ var $dialogs, $pages = $( ":jqmData(role='page')" );
- // if no pages are found, create one with body's inner html
+ // if no pages are found, check for dialogs or create one with body's inner html
if ( !$pages.length ) {
- $pages = $( "body" ).wrapInner( "<div data-" + $.mobile.ns + "role='page'></div>" ).children( 0 );
+ $dialogs = $( ":jqmData(role='dialog')" );
+
+ // if there are no pages but a dialog is present, load it as a page
+ if( $dialogs.length ) {
+ // alter the attribute so it will be treated as a page unpon enhancement
+ // TODO allow for the loading of a dialog as the first page (many considerations)
+ $dialogs.first().attr( "data-" + $.mobile.ns + "role", "page" );
+
+ // remove the first dialog from the set of dialogs since it's now a page
+ // add it to the empty set of pages to be loaded by the initial changepage
+ $pages = $pages.add( $dialogs.get().shift() );
+ } else {
+ $pages = $( "body" ).wrapInner( "<div data-" + $.mobile.ns + "role='page'></div>" ).children( 0 );
+ }
}
+
// add dialogs, set data-url attrs
$pages.add( ":jqmData(role='dialog')" ).each(function() {
var $this = $(this);

0 comments on commit 26c1d8e

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