Gnuffo1
Gnuffo1

Reputation: 3546

jQuery Mobile - form doesn't submit the submit button name and value

Normally this form:

<form method="post">
    <input type="submit" name="submit" value="Submit Form"/>
</form>

Would populate the POST array like this:

array(
    "submit" => "Submit Form"
);

However with jQuery mobile, any input type="submit" or input type="image" elements do not have values created in the POST array. This makes it impossible on forms with more than one button to tell which button was pressed.

I can use data-ajax="false" on the form tag to entirely disable jQuery Mobile from taking over the submission of the form and just submit as a normal HTML form, but then I lose the transition effects.

Is it possible to submit the name and value of the pressed submit button while retaining the effects of jQuery Mobile?

UPDATE: turns out this only happens when you specify data-role="none" on the input tag, which I have done so that I can style them manually instead of using the jQuery Mobile theme. As soon as I take off data-role="none" it works, but obviously I want to be able to submit the values AND have data-role="none".

Upvotes: 2

Views: 1454

Answers (1)

destan
destan

Reputation: 4411

it might be related the type="submit" try type="button" but in this case you need to manually submit the form via attaching something to onClick event or so.

Upvotes: 1

Related Questions