Skip to content
This repository
Browse code

Added support for data-role="dialog". When a dialog is the first "pag…

…e"-type element in the DOM, jQM will enhance it, triggering dialog enhancements as usual for non-ajax environments. Updated the /docs/pages/dialog.html page's role to date-role="dialog" to demonstrate the change. Fixes #3276.
  • Loading branch information...
commit 95bffbb231162068a7505f6ff8bc597d1e2b598c 1 parent 522543e
authored February 23, 2012
2  docs/pages/dialog.html
@@ -14,7 +14,7 @@
14 14
 </head> 
15 15
 <body> 
16 16
 
17  
-<div data-role="page">
  17
+<div data-role="dialog">
18 18
 	
19 19
 		<div data-role="header" data-theme="d">
20 20
 			<h1>Dialog</h1>
23  js/jquery.mobile.init.js
@@ -93,29 +93,10 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
93 93
 		// find and enhance the pages in the dom and transition to the first page.
94 94
 		initializePage: function() {
95 95
 			// find present pages
96  
-			var $dialogs, $pages = $( ":jqmData(role='page')" );
97  
-
98  
-			// if no pages are found, check for dialogs or create one with body's inner html
99  
-			if ( !$pages.length ) {
100  
-				$dialogs = $( ":jqmData(role='dialog')" );
101  
-
102  
-				// if there are no pages but a dialog is present, load it as a page
103  
-				if( $dialogs.length ) {
104  
-					// alter the attribute so it will be treated as a page unpon enhancement
105  
-					// TODO allow for the loading of a dialog as the first page (many considerations)
106  
-					$dialogs.first().attr( "data-" + $.mobile.ns + "role", "page" );
107  
-
108  
-					// remove the first dialog from the set of dialogs since it's now a page
109  
-					// add it to the empty set of pages to be loaded by the initial changepage
110  
-					$pages = $pages.add( $dialogs.get().shift() );
111  
-				} else {
112  
-					$pages = $( "body" ).wrapInner( "<div data-" + $.mobile.ns + "role='page'></div>" ).children( 0 );
113  
-				}
114  
-			}
115  
-
  96
+			var $pages = $( ":jqmData(role='page'), :jqmData(role='dialog')" );
116 97
 
117 98
 			// add dialogs, set data-url attrs
118  
-			$pages.add( ":jqmData(role='dialog')" ).each(function() {
  99
+			$pages.each(function() {
119 100
 				var $this = $(this);
120 101
 
121 102
 				// unless the data url is already set set it to the pathname

0 notes on commit 95bffbb

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