Skip to content

Commit

Permalink
fix: adding multiple listeners to the same element
Browse files Browse the repository at this point in the history
  • Loading branch information
to23mas committed Oct 23, 2024
1 parent 0105ca3 commit 277ca60
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions assets/plugins/features/autosubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export class AutosubmitPlugin implements DatagridPlugin {
const form = submitEl.closest("form");
if (!form) return;

if (submitEl.dataset.listenersAttached === "true") {
return; // Skip if listeners are already attached
}
submitEl.dataset.listenersAttached = "true";

// Select auto-submit
if (submitEl instanceof HTMLSelectElement) {
submitEl.addEventListener("change", () => datagrid.ajax.submitForm(form));
Expand Down

0 comments on commit 277ca60

Please sign in to comment.