From b23c38a0d46f4eab8586dc7b7843298773cef082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Mitermite?= Date: Tue, 24 Apr 2018 10:08:12 +0200 Subject: [PATCH 1/2] Adds the support of the formaction attribute An HTML form can have multiple submit buttons with differents actions. In this case, the [HTML5 formaction attribute](https://www.w3schools.com/tags/att_input_formaction.asp) overrides the action attribute of the form element. --- src/jquery.unobtrusive-ajax.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jquery.unobtrusive-ajax.js b/src/jquery.unobtrusive-ajax.js index ab71c5e..af753cf 100644 --- a/src/jquery.unobtrusive-ajax.js +++ b/src/jquery.unobtrusive-ajax.js @@ -172,7 +172,7 @@ return; } asyncRequest(this, { - url: this.action, + url: clickTarget && clickTarget.attr('formaction') || this.action, type: this.method || "GET", data: clickInfo.concat($(this).serializeArray()) }); From b41a73384ee9558d355454ea9a488535232ba980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Mitermite?= Date: Fri, 7 Feb 2020 10:46:31 +0100 Subject: [PATCH 2/2] Adds the support of the formmethod attribute --- src/jquery.unobtrusive-ajax.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jquery.unobtrusive-ajax.js b/src/jquery.unobtrusive-ajax.js index af753cf..4184b1c 100644 --- a/src/jquery.unobtrusive-ajax.js +++ b/src/jquery.unobtrusive-ajax.js @@ -172,8 +172,8 @@ return; } asyncRequest(this, { - url: clickTarget && clickTarget.attr('formaction') || this.action, - type: this.method || "GET", + url: clickTarget && clickTarget.attr("formaction") || this.action, + type: clickTarget && clickTarget.attr("formmethod") || this.method || "GET", data: clickInfo.concat($(this).serializeArray()) }); });