Submit Button-Value is not submitted on ajax-form-submit
This is a (multiple allowed):
-
[x] bug
-
[ ] enhancement
-
[ ] feature-discussion (RFC)
-
Framework7 Version: 1.5
-
Platform and Target: Android/iOS
I have a form with class="ajax-submit" and a submit button with a name and a value. The name-value pair of the submit button is not sent as it would be on a normal form-submit. If a submit-button is pressed, the value of that button should be submitted. If the form is submitted in another way like pressing "enter", the value of the first submit-button should be used.
I even display the page after the submit - it would be nice, if there would be a special class name for doing something like that automatically:
myApp.onPageInit('*', function(){
$('form.ajax-submit').on('submitted', function (e) {
mainView.router.loadContent(e.detail.data);
});
});
why are you using jquery selector? what is your framework selector? $$ ??
$ is my framework7 selector, I only use that (no jquery)
It would be good to see your HTML as well as your JavaScript
The problem is in the following framework7 code:
form = $(form);
if (form.length !== 1) return false;
// Skip input types
var skipTypes = ['submit', 'image', 'button', 'file'];
var skipNames = [];
form.find('input, select, textarea').each(function () {
...
...
Submit and image types should not be skipped! In a normal html form with a submit button like
<input type="submit" name="myname" value="my value"/>
The field "myname" is always submitted. And as I wrote in my initial request, even when submitted via the enter/return key, always the value of the first submit button is submitted. This may also be of type "image".
I have made a codepen example, but its pretty useless, because you have to inspect, that the button name-value pair will not be submitted:
https://codepen.io/anon/pen/aWzYKr
On a normal form (without ajax) it would.
This is usefull for submitting the same form with different buttons (=different actions).
This problem is still in v2. A fix should be simple I think:
- if the form is submitted with a submit-button-click, then, if the button has a "name" attribute, its value should also be submitted
- if the form is submitted without a button, always the first submit-button-name-value-pair of the form should be submitted This is how forms are handled by standard html.