From 3df24fab6d1757979f1302f546b1fc83b5373993 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Tue, 25 Jan 2011 00:29:19 -0500 Subject: [PATCH] fixed a regression in safari where images wouldn't load properly because base was being set after html was appended. --- js/jquery.mobile.navigation.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index cb4069e4..c4703ab1 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -458,14 +458,9 @@ data: data, success: function( html ) { - - var all = $("
"); - //workaround to allow scripts to execute when included in page divs - all.get(0).innerHTML = html; - to = all.find('[data-role="page"], [data-role="dialog"]').first(); - - //if page arrives with a data-url, use it as the new fileUrl, base path, etc - var redirectLoc = to.data( "url" ); + //pre-parse html to check for a data-url, + //use it as the new fileUrl, base path, etc + var redirectLoc = / data-url="(.*)"/.test( html ) && RegExp.$1; if( redirectLoc ){ if(base){ @@ -477,8 +472,12 @@ if(base){ base.set(fileUrl); } - to.attr( "data-url", fileUrl ); } + + var all = $("
"); + //workaround to allow scripts to execute when included in page divs + all.get(0).innerHTML = html; + to = all.find('[data-role="page"], [data-role="dialog"]').first(); //rewrite src and href attrs to use a base url if( !$.support.dynamicBaseTag ){ @@ -497,7 +496,9 @@ } //append to page and enhance - to.appendTo( $.mobile.pageContainer ); + to + .attr( "data-url", fileUrl ) + .appendTo( $.mobile.pageContainer ); enhancePage(); transitionPages();