mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 18:16:22 +00:00
fixup! fixup! fix: no enviar el formulario si tiene algún atributo de htmx
This commit is contained in:
parent
ce3ab24dc0
commit
99e965d4da
4 changed files with 13 additions and 7 deletions
|
@ -28,12 +28,16 @@ export default class extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
submit(event = undefined) {
|
submit(event = undefined) {
|
||||||
|
if (this.submitting) return;
|
||||||
|
|
||||||
|
this.submitting = true;
|
||||||
|
|
||||||
event?.preventDefault();
|
event?.preventDefault();
|
||||||
|
|
||||||
if (this.element.reportValidity()) {
|
if (this.element.reportValidity()) {
|
||||||
this.element.classList.remove("was-validated");
|
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 } }));
|
window.dispatchEvent(new CustomEvent("notification:show", { detail: { id: this.submittingIdValue } }));
|
||||||
} else {
|
} else {
|
||||||
|
@ -43,5 +47,7 @@ export default class extends Controller {
|
||||||
|
|
||||||
window.dispatchEvent(new CustomEvent("notification:show", { detail: { id: this.invalidIdValue } }));
|
window.dispatchEvent(new CustomEvent("notification:show", { detail: { id: this.invalidIdValue } }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.submitting = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,5 +41,5 @@ Rails.start()
|
||||||
Turbolinks.start()
|
Turbolinks.start()
|
||||||
ActiveStorage.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;
|
window.htmx.config.selfRequestsOnly = true;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"@rails/ujs": "^6.1.3-1",
|
"@rails/ujs": "^6.1.3-1",
|
||||||
"@rails/webpacker": "5.4.4",
|
"@rails/webpacker": "5.4.4",
|
||||||
"@suttyweb/editor": "^0.1.29",
|
"@suttyweb/editor": "^0.1.29",
|
||||||
"@suttyweb/htmx.org": "^1.9.13",
|
"@suttyweb/htmx.org": "2.0.0",
|
||||||
"babel-loader": "^8.2.2",
|
"babel-loader": "^8.2.2",
|
||||||
"bs-custom-file-input": "^1.3.4",
|
"bs-custom-file-input": "^1.3.4",
|
||||||
"chart.js": "^3.5.1",
|
"chart.js": "^3.5.1",
|
||||||
|
|
|
@ -1984,10 +1984,10 @@
|
||||||
linkifyjs "^4.1.1"
|
linkifyjs "^4.1.1"
|
||||||
prosemirror-svelte-nodeview "^1.0.2"
|
prosemirror-svelte-nodeview "^1.0.2"
|
||||||
|
|
||||||
"@suttyweb/htmx.org@^1.9.13":
|
"@suttyweb/htmx.org@2.0.0":
|
||||||
version "1.9.13"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@suttyweb/htmx.org/-/htmx.org-1.9.13.tgz#bc67a5e2947d7cc125649b829610da8ee61f21af"
|
resolved "https://registry.yarnpkg.com/@suttyweb/htmx.org/-/htmx.org-2.0.0.tgz#44435d834d143ae9b60daa454f68f8e72e6ebd7f"
|
||||||
integrity sha512-/2x3AGXT2CFOmp8Nf59XY2brah5wSo4YvcctYA2zD4BByNft4XE0rUk4VM7TjPxR1LOzg6VK1crZmdiy3JyzxQ==
|
integrity sha512-EJk9s8judGLIZ6c9N779z91WHPIfAkwkVY5QF7WH2ZT2Kt03k/hAoy7P4NjYreFIQcIo8d+TU/CIhViCmB4c0Q==
|
||||||
|
|
||||||
"@types/caseless@*":
|
"@types/caseless@*":
|
||||||
version "0.12.2"
|
version "0.12.2"
|
||||||
|
|
Loading…
Reference in a new issue