mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-05-04 04:44:42 +00:00
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
This commit is contained in:
parent
39476d151a
commit
61005944d3
2 changed files with 5 additions and 3 deletions
|
|
@ -22,7 +22,8 @@
|
||||||
|
|
||||||
<h2>Ajax form submission</h2>
|
<h2>Ajax form submission</h2>
|
||||||
|
|
||||||
<p>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 <code>action</code> and <code>method</code> properties on your form element.</p>
|
<p>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 <code>action</code> and <code>method</code> properties on your form element. When unspecified, the method will default to <code>get</code>, and the <code>action</code> will default to the current page's relative path (found via <code>$.mobile.path.get()</code></p>
|
||||||
|
<p>Forms also accept attributes for transitions just like anchors, such as <code>data-transition="pop"</code> and <code>data-direction="reverse"</code>. To submit a form without Ajax, you can either disable Ajax form handling globally, or per form via the <code>data-ajax="false"</code> attribute. The <code>target</code> attribute (as in <code>target="_blank"</code>) 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 <code>rel</code> attribute is not allowed on forms.</p>
|
||||||
|
|
||||||
<h2>Non-Ajax handling</h2>
|
<h2>Non-Ajax handling</h2>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -622,10 +622,11 @@
|
||||||
$(this).is( "[data-ajax='false']" ) ){ return; }
|
$(this).is( "[data-ajax='false']" ) ){ return; }
|
||||||
|
|
||||||
var type = $(this).attr("method"),
|
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
|
//external submits use regular HTTP
|
||||||
if( path.isExternal( url ) ){
|
if( path.isExternal( url ) || target ){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue