mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-19 13:51:00 +00:00
If a [data-role="page"] div has an ID already when it is loaded, mobilize will wrap the page in a new div, transferring page-related data attrs to the wrapper (role,theme,fullscreen).
This prevents a ID from being overwritten for use in our page navigation model, which would have prevented css and scripting from applying. Fixes #93
This commit is contained in:
parent
dc3ff3b67e
commit
85c063eb94
1 changed files with 23 additions and 2 deletions
|
|
@ -201,6 +201,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
//wrap page and transfer data-attrs if it has an ID
|
||||
function wrapNewPage( newPage ){
|
||||
var copyAttrs = ['data-role', 'data-theme', 'data-fullscreen'], //TODO: more page-level attrs?
|
||||
wrapper = newPage.wrap( "<div>" ).parent();
|
||||
|
||||
$.each(copyAttrs,function(i){
|
||||
if( newPage.attr( copyAttrs[ i ] ) ){
|
||||
wrapper.attr( copyAttrs[ i ], newPage.attr( copyAttrs[ i ] ) );
|
||||
newPage.removeAttr( copyAttrs[ i ] );
|
||||
}
|
||||
});
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
if ( url ) {
|
||||
// see if content is present already
|
||||
var localDiv = jQuery( "[id='" + url + "']" );
|
||||
|
|
@ -227,8 +241,15 @@
|
|||
// setPageRole( newPage );
|
||||
// mobilize( newPage );
|
||||
// changePage( jQuery( ".ui-page-active" ), newPage, transition, back );
|
||||
jQuery( this ).replaceWith(
|
||||
jQuery( this ).find( '[data-role="page"]' ).eq( 0 ).attr( "id", fileUrl ) );
|
||||
|
||||
//find new page div
|
||||
var newPage = jQuery( this ).find( '[data-role="page"]' ).eq( 0 );
|
||||
if( newPage.attr('id') ){
|
||||
newPage = wrapNewPage( newPage );
|
||||
|
||||
}
|
||||
|
||||
jQuery( this ).replaceWith( newPage.attr( "id", fileUrl ) );
|
||||
var newPage = jQuery( "[id='" + fileUrl + "']" );
|
||||
setPageRole( newPage );
|
||||
mobilize( newPage );
|
||||
|
|
|
|||
Loading…
Reference in a new issue