Permalink
Browse files

Navigation: When submitting a form via GET, strip query off URL befor…

…e creating new query string. Fixes #5710.

(cherry picked from commit 0d4e839)
  • Loading branch information...
1 parent 90e8f63 commit 92b813f902b18971473e9791be49c75da1dd17d0 @gabrielschulhof gabrielschulhof committed Mar 14, 2013
Showing with 14 additions and 2 deletions.
  1. +14 −2 js/jquery.mobile.navigation.js
@@ -997,7 +997,7 @@ define( [
$.mobile.navreadyDeferred = $.Deferred();
$.mobile._registerInternalEvents = function() {
var getAjaxFormData = function( $form, calculateOnly ) {
- var type, target, url, ret = true, formData, vclickedName;
+ var type, target, url, ret = true, formData, vclickedName, method;
if ( !$.mobile.ajaxEnabled ||
// test that the form is, itself, ajax false
$form.is( ":jqmData(ajax='false')" ) ||
@@ -1009,6 +1009,11 @@ define( [
target = $form.attr( "target" );
url = $form.attr( "action" );
+ method = ( $form.attr( "method" ) || "get" ).toLowerCase();
+
+ if ( target ) {
+ return false;
+ }
// If no action is specified, browsers default to using the
// URL of the document containing the form. Since we dynamically
@@ -1018,6 +1023,13 @@ define( [
if ( !url ) {
// Get the @data-url for the page containing the form.
url = getClosestBaseUrl( $form );
+
+ // NOTE: If the method is "get", we need to strip off the query string
+ // because it will get replaced with the new form data. See issue #5710.
+ if ( method === "get" ) {
+ url = path.parseUrl( url ).hrefNoSearch;
+ }
+
if ( url === documentBase.hrefNoHash ) {
// The url we got back matches the document base,
// which means the page must be an internal/embedded page,
@@ -1029,7 +1041,7 @@ define( [
url = path.makeUrlAbsolute( url, getClosestBaseUrl( $form ) );
- if ( ( path.isExternal( url ) && !path.isPermittedCrossDomainRequest( documentUrl, url ) ) || target ) {
+ if ( ( path.isExternal( url ) && !path.isPermittedCrossDomainRequest( documentUrl, url ) ) ) {
return false;
}

0 comments on commit 92b813f

Please sign in to comment.