File tree Expand file tree Collapse file tree 4 files changed +51
-0
lines changed
Expand file tree Collapse file tree 4 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 7373 initializePage : function ( ) {
7474 //find present pages
7575 var $pages = $ ( ":jqmData(role='page')" ) ;
76+
77+ //if no pages are found, create one with body's inner html
78+ if ( ! $pages . length ) {
79+ $pages = $ ( "body" ) . wrapInner ( "<div data-" + $ . mobile . ns + "role='page'></div>" ) . children ( 0 ) ;
80+ console . log ( "page wasn't needed" )
81+ }
7682
7783 //add dialogs, set data-url attrs
7884 $pages . add ( ":jqmData(role='dialog')" ) . each ( function ( ) {
Original file line number Diff line number Diff line change 648648 && RegExp . $1 ) {
649649 url = fileUrl = path . getFilePath ( RegExp . $1 ) ;
650650 }
651+ else {
652+
653+ }
651654
652655 if ( base ) {
653656 base . set ( fileUrl ) ;
656659 //workaround to allow scripts to execute when included in page divs
657660 all . get ( 0 ) . innerHTML = html ;
658661 page = all . find ( ":jqmData(role='page'), :jqmData(role='dialog')" ) . first ( ) ;
662+
663+ //if page elem couldn't be found, create one and insert the body element's contents
664+ if ( ! page . length ) {
665+ page = $ ( "<div data-" + $ . mobile . ns + "role='page'>" + html . split ( / < \/ ? b o d y [ ^ > ] * > / gmi ) [ 1 ] + "</div>" ) ;
666+ }
659667
660668 if ( newPageTitle && ! page . jqmData ( "title" ) ) {
661669 page . jqmData ( "title" , newPageTitle ) ;
Original file line number Diff line number Diff line change 212212 } , 500 ) ;
213213 } ) ;
214214
215+ asyncTest ( "page element is generated when not present in initial markup" , function ( ) {
216+ expect ( 1 ) ;
217+
218+ $ ( "<iframe src='nopage.html'>" ) . appendTo ( "body" ) . load ( function ( ) {
219+ ok ( $ ( this ) . contents ( ) . find ( ".ui-page" ) . length , 1 ) ;
220+ $ ( this ) . remove ( ) ;
221+ start ( ) ;
222+ } ) ;
223+ } ) ;
224+
225+ asyncTest ( "page element is generated when not present in ajax'd markup" , function ( ) {
226+ expect ( 1 ) ;
227+ $ . mobile . changePage ( "nopage.html" ) ;
228+
229+ $ ( ":jqmData(url$='nopage.html')" ) . live ( "pagecreate" , function ( ) {
230+ ok ( true , "page was created from dynamically loaded HTML that contained no page div" ) ;
231+ start ( ) ;
232+ } ) ;
233+ } ) ;
234+
235+
236+
215237 } ) ;
216238} ) ( jQuery ) ;
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < title > jQuery Mobile Init Test Suite</ title >
6+ < script src ="../../../js/jquery.js "> </ script >
7+ < script src ="../jquery.setNameSpace.js "> </ script >
8+ < script src ="../../../js/ "> </ script >
9+
10+ </ head >
11+
12+ < p > testing</ p >
13+
14+ </ body >
15+ </ html >
You can’t perform that action at this time.
0 commit comments