[UPDT] HORILLA: Prevent duplicate select2 event triggers on HTMX updates

This commit is contained in:
Horilla
2025-07-05 15:39:50 +05:30
parent 5cae06549a
commit f980d5daa3
8 changed files with 21 additions and 49 deletions

View File

@@ -3999,17 +3999,25 @@
});
staticUrl = $("#statiUrl").attr("data-url");
$(document).on("htmx:afterRequest", function (event, data) {
var response = event.detail.xhr.response;
var target = $(event.detail.elt.getAttribute("hx-target"));
target.find(".oh-select").select2();
$(document).ready(function () {
$(".oh-select").select2({
width: '100%'
});
$("select").on("select2:select", function (e) {
$(this).closest("select")[0].dispatchEvent(new Event("change"));
});
})
$(document).on("htmx:afterSettle", function (event) {
var target = $(event.target);
target.find(".oh-select").select2({ width: '100%' });
target.find("select").off("select2:select").on("select2:select", function (e) {
this.dispatchEvent(new Event("change"));
console.log('__11___');
});
});
$(document).on("htmx:afterSettle", function (event, data) {
var response = event.detail.xhr.response;
target = $(event.target);
target.find(".oh-select").select2();
});
// Helper function to hash data using SHA-256
async function hashData(data) {