-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Toggle [disabled] on form submitter (#386)
During a form submission, toggle the [disabled][] attribute on prior to `turbo:submit-start`, and remove it prior to firing `turbo:submit-end`. If callers need to control the submitter's [disabled][] attribute more finely, they can declare listeners to do so. Combined with CSS rules, consumer applications can hide and show submission text similar to RailsUJS's support for `data-disable-with`: ```css button .show-when-disabled { display: none; } button[disabled] .show-when-disabled { display: initial; } button .show-when-enabled { display: initial; } button[disabled] .show-when-enabled { display: none; } ``` ```html <button> <span class="show-when-enabled">Submit</span> <span class="show-when-disabled">Submitting...</span> </button> ``` Styling descendant submitters based on their ancestors is only possible with `<button>` elements, since `<input type="submit">` do not have text content or descendants of their own. [disabled]: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
- Loading branch information
1 parent
dbd1e9b
commit 7b54d10
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters