5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 12:56:22 +00:00

fixup! fixup! fix: no enviar el formulario si tiene algún atributo de htmx

This commit is contained in:
f 2024-06-25 14:24:12 -03:00
parent ce3ab24dc0
commit 99e965d4da
No known key found for this signature in database
4 changed files with 13 additions and 7 deletions

View file

@ -28,12 +28,16 @@ export default class extends Controller {
}
submit(event = undefined) {
if (this.submitting) return;
this.submitting = true;
event?.preventDefault();
if (this.element.reportValidity()) {
this.element.classList.remove("was-validated");
if (this.element.getAttributeNames().some(x => x.startsWith("hx-"))) this.element.submit();
if (!this.element.getAttributeNames().some(x => x.startsWith("hx-"))) this.element.submit();
window.dispatchEvent(new CustomEvent("notification:show", { detail: { id: this.submittingIdValue } }));
} else {
@ -43,5 +47,7 @@ export default class extends Controller {
window.dispatchEvent(new CustomEvent("notification:show", { detail: { id: this.invalidIdValue } }));
}
this.submitting = false;
}
}

View file

@ -41,5 +41,5 @@ Rails.start()
Turbolinks.start()
ActiveStorage.start()
window.htmx = require("@suttyweb/htmx.org/dist/htmx.js");
window.htmx = require("@suttyweb/htmx.org/dist/htmx.cjs.js");
window.htmx.config.selfRequestsOnly = true;

View file

@ -14,7 +14,7 @@
"@rails/ujs": "^6.1.3-1",
"@rails/webpacker": "5.4.4",
"@suttyweb/editor": "^0.1.29",
"@suttyweb/htmx.org": "^1.9.13",
"@suttyweb/htmx.org": "2.0.0",
"babel-loader": "^8.2.2",
"bs-custom-file-input": "^1.3.4",
"chart.js": "^3.5.1",

View file

@ -1984,10 +1984,10 @@
linkifyjs "^4.1.1"
prosemirror-svelte-nodeview "^1.0.2"
"@suttyweb/htmx.org@^1.9.13":
version "1.9.13"
resolved "https://registry.yarnpkg.com/@suttyweb/htmx.org/-/htmx.org-1.9.13.tgz#bc67a5e2947d7cc125649b829610da8ee61f21af"
integrity sha512-/2x3AGXT2CFOmp8Nf59XY2brah5wSo4YvcctYA2zD4BByNft4XE0rUk4VM7TjPxR1LOzg6VK1crZmdiy3JyzxQ==
"@suttyweb/htmx.org@2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@suttyweb/htmx.org/-/htmx.org-2.0.0.tgz#44435d834d143ae9b60daa454f68f8e72e6ebd7f"
integrity sha512-EJk9s8judGLIZ6c9N779z91WHPIfAkwkVY5QF7WH2ZT2Kt03k/hAoy7P4NjYreFIQcIo8d+TU/CIhViCmB4c0Q==
"@types/caseless@*":
version "0.12.2"