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

Commit b01478a

Browse files
author
scottjehl
committed
make sure forms can submit via ajax AND pass the clicked button's name/value in the serialized data. Fixes #605
1 parent e765d21 commit b01478a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

js/jquery.mobile.forms.button.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,21 @@ $.widget( "mobile.button", $.mobile.widget, {
3131
} )
3232
.text( $el.text() || $el.val() )
3333
.insertBefore( $el )
34-
.click(function(){
34+
.click(function(e){
3535
if(!o.disabled){
36-
$el.click();
36+
if ( $el.attr("type") !== "reset" ){
37+
var $buttonPlaceholder = $("<input>",
38+
{type: "hidden", name: $el.attr("name"), value: $el.attr("value")})
39+
.insertBefore($el);
40+
41+
}
42+
$el.submit();
43+
$buttonPlaceholder.remove();
3744
}
38-
39-
return false;
45+
else{
46+
$el.trigger("click")
47+
}
48+
e.preventDefault();
4049
})
4150
.buttonMarkup({
4251
theme: o.theme,

0 commit comments

Comments
 (0)