Skip to content

Commit 95bffbb

Browse files
author
scottjehl
committed
Added support for data-role="dialog". When a dialog is the first "page"-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 jquery-archive#3276.
1 parent 522543e commit 95bffbb

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

docs/pages/dialog.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</head>
1515
<body>
1616

17-
<div data-role="page">
17+
<div data-role="dialog">
1818

1919
<div data-role="header" data-theme="d">
2020
<h1>Dialog</h1>

js/jquery.mobile.init.js

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -93,29 +93,10 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
9393
// find and enhance the pages in the dom and transition to the first page.
9494
initializePage: function() {
9595
// 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')" );
11697

11798
// add dialogs, set data-url attrs
118-
$pages.add( ":jqmData(role='dialog')" ).each(function() {
99+
$pages.each(function() {
119100
var $this = $(this);
120101

121102
// unless the data url is already set set it to the pathname

0 commit comments

Comments
 (0)