From 7cca88b4f3ce0845cdbdfb55885b406b89199d1d Mon Sep 17 00:00:00 2001 From: f Date: Wed, 10 Apr 2024 12:15:30 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20al=20salir=20de=20la=20p=C3=A1gina,=20ca?= =?UTF-8?q?ncelar=20todas=20las=20peticiones=20de=20htmx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #15880 closes #15881 closes #15883 closes #15884 closes #15893 closes #15894 closes #15973 closes #15974 closes #15975 closes #16003 closes #16004 --- app/javascript/etc/htmx_abort.js | 7 +++++++ app/javascript/etc/index.js | 1 + 2 files changed, 8 insertions(+) create mode 100644 app/javascript/etc/htmx_abort.js diff --git a/app/javascript/etc/htmx_abort.js b/app/javascript/etc/htmx_abort.js new file mode 100644 index 00000000..308d0315 --- /dev/null +++ b/app/javascript/etc/htmx_abort.js @@ -0,0 +1,7 @@ +// Cancela las peticiones pendientes de htmx para todos los elementos al +// cambiar de página. +document.addEventListener("turbolinks:click", () => { + for (const hx of document.querySelectorAll("[hx-get]")) { + window.htmx.trigger(hx, "htmx:abort"); + } +}); diff --git a/app/javascript/etc/index.js b/app/javascript/etc/index.js index d4b9f7a3..9ee6a95a 100644 --- a/app/javascript/etc/index.js +++ b/app/javascript/etc/index.js @@ -7,3 +7,4 @@ import './timezone' import './turbolinks-anchors' import './validation' import './new_editor' +import './htmx_abort'