jquery-pjax
jquery-pjax copied to clipboard
Support HTML5 `formaction` attribute
Pjax does not use formation on a input type="submit".
Steps to duplicate:
- Create Form with pjax submission with action being a different page or query.
- Test Form. It will work and use the form's action attribute to change the url.
- Now add a submit button with a formaction different than that of the form itself.
- Submit via Pjax. The URL from the form's action's attribute will be used rather than the formaction on the submit.
This library doesn't yet support emerging HTML5 standards like formaction. It might in the future.
I solved the problem like this:
$(document).on("submit", "form[data-pjax]", function (event) { var config = {}; var url = $(":input[type=submit][formaction]:focus", $(this)).attr("formaction"); if (url) { config.url = url; } $.pjax.submit(event, "#Container", config); });