Skip to content

Submitting button value #295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

kim3er
Copy link
Contributor

@kim3er kim3er commented Jun 21, 2013

$.pjax.submit does not record the value of the submitting element.

On a standard form post, the value of the submitting button is passed along with the form data. This can be useful for describing the intent of a user.

For instance a form my have three submitting button; 'Save', 'Preview' or 'Publish'. The intent of the user can be established server side using the the button's value.

This is obviously not always a requirement, so $.pjax.submit is still a very useful function. However by attaching the handler to the submit event it is not possible, as far as I'm aware, to establish the value of the clicked button. This I assume is because the a form doesn't need a button in most browsers to fire that event.

So I have moved the logic from $.pjax.submit into and internal function called formSubmissionHandler and add an additional wrapper to the formSubmissionHandler called $.pjax.submitClick.

$.pjax.submitClick does the same as $.pjax.submit, but it is attached to the submitting elements of a form. This allows the submission handler to also identify the submitting element and record the value if one is present.

Rich

@kim3er
Copy link
Contributor Author

kim3er commented Jul 19, 2013

Hi, is there any interest in this pull request? I've found very useful. Rich

@mislav
Copy link
Collaborator

mislav commented May 6, 2014

Thanks for raising this issue. I believe that we should include the submit button name+value automatically, not with a special method. The pjax submit should send the form indentically as a browser would do natively.

I would take a look at this PR if it was done in a cleaner way. Take a look at how rails-behaviors detects submit buttons; we don't need to do absolutely the same approach (hidden element) but we do need something similar.

@kim3er
Copy link
Contributor Author

kim3er commented May 11, 2014

Open new PR based on @mislav's comments. #390

@kim3er kim3er closed this May 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants