From 61005944d3b13f1daeaba5760bbc805b66d42ce9 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Thu, 24 Mar 2011 00:59:42 -0400 Subject: [PATCH] Added support for the target attribute on forms (such as target="_blank"). When set, the form handler simply allows the native handling to apply. Unlike anchors however, the rel attribute is not allowed on forms. If you're purely looking to submit a single form without ajax, you can use the data-ajax="false" attribute as well. Fixes #952 and docs updates are included --- docs/forms/forms-sample.html | 3 ++- js/jquery.mobile.navigation.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/forms/forms-sample.html b/docs/forms/forms-sample.html index cfe320aa..fdcee602 100755 --- a/docs/forms/forms-sample.html +++ b/docs/forms/forms-sample.html @@ -22,7 +22,8 @@

Ajax form submission

-

In jQuery Mobile, form submissions are automatically handled using Ajax whenever possible, creating a smooth transition between the form and the result page. To ensure your form submits as intended, be sure to specify action and method properties on your form element.

+

In jQuery Mobile, form submissions are automatically handled using Ajax whenever possible, creating a smooth transition between the form and the result page. To ensure your form submits as intended, be sure to specify action and method properties on your form element. When unspecified, the method will default to get, and the action will default to the current page's relative path (found via $.mobile.path.get()

+

Forms also accept attributes for transitions just like anchors, such as data-transition="pop" and data-direction="reverse". To submit a form without Ajax, you can either disable Ajax form handling globally, or per form via the data-ajax="false" attribute. The target attribute (as in target="_blank") is respected on forms as well, and will default to the browser's handling of that target when the form submits. Note that unlike anchors, the rel attribute is not allowed on forms.

Non-Ajax handling

diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 6449fd05..837cd21b 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -622,10 +622,11 @@ $(this).is( "[data-ajax='false']" ) ){ return; } var type = $(this).attr("method"), - url = path.clean( $(this).attr( "action" ) ); + url = path.clean( $(this).attr( "action" ) ), + target = $(this).attr("target"); //external submits use regular HTTP - if( path.isExternal( url ) ){ + if( path.isExternal( url ) || target ){ return; }