Skip to content
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

Scrum 1670 inject submit child element #1187

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/pat/ajax/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright 2012-2013 Florian Friesdorf
* Copyright 2012-2013 Marko Durkovic
*/
import "../../core/polyfills"; // SubmitEvent.submitter for Safari < 15.4 and jsDOM
import $ from "jquery";
import logging from "../../core/logging";
import Parser from "../../core/parser";
Expand Down Expand Up @@ -53,8 +54,8 @@ const _ = {
$el.off(".pat-ajax");
},
onClickSubmit(event) {
const el = event.target;
const form = el.closest("form");
const el = event.submitter || event.target;
const form = el.form;
const data = {};
if (el.name) {
data[el.name] = el.value;
Expand Down
13 changes: 3 additions & 10 deletions src/pat/inject/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,18 @@ const inject = {
if ($el[0]?.tagName === "FORM") {
events.add_event_listener(
$el[0],
"click",
"pat-inject--form-submit-click",
"submit",
"pat-inject--form-submit",
(e) => {
if (
e.target.matches(
e.submitter?.matches(
"[type=submit], button:not([type=button]), [type=image]"
)
) {
// make sure the submitting button is sent
// with the form
ajax.onClickSubmit(e);
}
}
);
events.add_event_listener(
$el[0],
"submit",
"pat-inject--form-submit",
(e) => {
this.onTrigger(e);
}
);
Expand Down
Loading