Button disabling/enabling

Closes #10
This commit is contained in:
2024-01-20 15:02:45 +01:00
parent 1ae5658ebe
commit 0e85a21d2c
3 changed files with 36 additions and 2 deletions

View File

@@ -2,6 +2,24 @@
import "@hotwired/turbo-rails"
function showPage(event) {
document.documentElement.style.visibility="visible";
document.documentElement.style.visibility="visible"
}
document.addEventListener('turbo:load', showPage)
Turbo.StreamActions.disable = function() {
this.targetElements.forEach((e) => {
e.setAttribute("disabled", "disabled")
e.setAttribute("aria-disabled", "true")
e.setAttribute("tabindex", "-1")
})
}
Turbo.StreamActions.enable = function() {
this.targetElements.forEach((e) => {
e.removeAttribute("disabled")
e.removeAttribute("aria-disabled")
// 'tabindex' is not used explicitly, so removing it is safe
e.removeAttribute("tabindex")
})
}
document.addEventListener('turbo:load', showPage);