jquery-form/form

button value not submitted with delegated ajaxForm()

ynamite opened this issue · 1 comments

Description:

I have multiple <button type="submit" value="x" name="product" /> in a form along with a bunch of text inputs.
According to the docs, the name and value of the clicked submit button are supposed to be incuded in the transmitted form data.
My code is as follows:

$('form').ajaxForm({
    target: '#my-form',
    replaceTarget: false,
    method: 'POST',
    delegation: true,
    beforeSubmit: function(formdata, $form, options) {
        return handleForm(formdata, $form.attr('id'));
    },
    success: formSuccessCallback
});

Expected Behavior:

Submitting the form should include the value (and name) of the clicked button.

Actual behavior:

All formdata is submitted, except the button name/value that submitted the form.

Versions:

jQuery Form Plugin: 4.3.0
jQuery: 3.6.0
Browsers: Firefox 88.0.1

Demonstration

May be specific to my project, lot's of stuff going on, so an isolated test case seems difficult to reproduce.

Steps to reproduce:

same as above. Not sure why the button value isn't submitted

I was able to fix it. There was another click event placed on the document with event.stopPropagation(); which canceled the necessary click event on the form buttons.