Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Fix for issue 1580 - phonegap: Pages with data-ajax="false" on form f…
Browse files Browse the repository at this point in the history
…ail to load

In the $.ajax() callback, we look for elements with @href, @src, and @data-ajax="false" elements, the code then assumes that matching elements will have either @href or @src, which of course forms don't ... they have @action ... so the code throws an exception because thisUrl is undefined.

- I reworked the code to handle action and check to make sure we have an attribute and url string before attempting to use them.
  • Loading branch information
jblas committed May 6, 2011
1 parent e775f5e commit e597ccb
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions js/jquery.mobile.navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,14 +606,27 @@
if( !$.support.dynamicBaseTag ) {
var newPath = path.get( fileUrl );
to.find( "[src], link[href], a[rel='external'], :jqmData(ajax='false'), a[target]" ).each( function() {
var thisAttr = $( this ).is( "[href]" ) ? "href" : "src",
thisUrl = $( this ).attr( thisAttr );

//if full path exists and is same, chop it - helps IE out
thisUrl = thisUrl.replace( location.protocol + "//" + location.host + location.pathname, "" );
var attrs = [ "href", "src", "action" ],
thisAttr = undefined,
thisUrl = undefined;

for (var i = 0; i < attrs.length; i++) {
var a = attrs[i],
v = $( this ).attr( a );
if (v) {
thisAttr = a;
thisUrl = v;
break;
}
}

if( ! /^(\w+:|#|\/)/.test( thisUrl ) ) {
$( this ).attr( thisAttr, newPath + thisUrl );
if ( thisAttr && thisUrl ) {
//if full path exists and is same, chop it - helps IE out
thisUrl = thisUrl.replace( location.protocol + "//" + location.host + location.pathname, "" );

if( ! /^(\w+:|#|\/)/.test( thisUrl ) ) {
$( this ).attr( thisAttr, newPath + thisUrl );
}
}
});
}
Expand Down

0 comments on commit e597ccb

Please sign in to comment.