Skip to content

Commit 3f49db3

Browse files
committed
document inherit keyword
1 parent bb4eb0f commit 3f49db3

3 files changed

Lines changed: 43 additions & 3 deletions

File tree

www/content/attributes/hx-disabled-elt.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Here is an example with a button that will disable itself during a request:
3232
When a request is in flight, this will cause the button to be marked with [the `disabled` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled),
3333
which will prevent further clicks from occurring.
3434

35-
The `hx-disabled-elt` attribute also supports specifying multiple CSS selectors separated by commas to disable multiple elements during the request. Here is an example that disables buttons and text input fields of a particular form during the request:
35+
The `hx-disabled-elt` attribute also supports specifying multiple CSS selectors separated by commas to disable multiple
36+
elements during the request. Here is an example that disables buttons and text input fields of a particular form during the request:
3637

3738
```html
3839
<form hx-post="/example" hx-disabled-elt="find input[type='text'], find button">
@@ -41,6 +42,19 @@ The `hx-disabled-elt` attribute also supports specifying multiple CSS selectors
4142
</form>
4243
```
4344

45+
Note that you can also use the `inherit` keyword to inherit parent values for a disabled elements and add additional
46+
disabled element CSS selectors:
47+
48+
```html
49+
<main hx-disabled-elt="#logout-button">
50+
...
51+
<form hx-post="/example" hx-disabled-elt="inherit, find input[type='text'], find button">
52+
<input type="text" placeholder="Type here...">
53+
<button type="submit">Send</button>
54+
</form>
55+
</main>
56+
```
57+
4458
## Notes
4559

4660
* `hx-disabled-elt` is inherited and can be placed on a parent element

www/content/attributes/hx-include.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,20 @@ Here is an example that includes a separate input value:
3131
This is a little contrived as you would typically enclose both of these elements in a `form` and submit
3232
the value automatically, but it demonstrates the concept.
3333

34-
Note that if you include a non-input element, all input elements enclosed in that element will be included.
34+
Note that you can also use the `inherit` keyword to inherit parent values for inclusion and add additional values:
35+
36+
```html
37+
<main hx-include="#hidden-input">
38+
...
39+
<button hx-post="/example" hx-include="inherit, [name='email']">
40+
Post It!
41+
</button>
42+
Enter email: <input name="email" type="email"/>
43+
</main>
44+
```
45+
46+
47+
Finally, note that if you include a non-input element, all input elements enclosed in that element will be included.
3548

3649
## Notes
3750

@@ -52,4 +65,4 @@ Note that if you include a non-input element, all input elements enclosed in tha
5265
to [document.querySelectorAll](https://developer.mozilla.org/docs/Web/API/Document/querySelectorAll) and will include
5366
multiple elements, while the extended selectors such as `find` or `next` only return a single element at most to
5467
include
55-
* `hx-include` will ignore disabled inputs
68+
* `hx-include` will ignore disabled inputs

www/content/attributes/hx-indicator.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ Here is an example with a spinner adjacent to the button:
2525
</div>
2626
```
2727

28+
Note that you can also use the `inherit` keyword to inherit parent values for an indicator and add additional indicator
29+
CSS selectors:
30+
31+
```html
32+
<main hx-indicator="#global-indicator">
33+
...
34+
<button hx-post="/example" hx-indicator="inherit, #spinner">
35+
Post It!
36+
</button>
37+
<img id="spinner" class="htmx-indicator" src="/img/bars.svg"/>
38+
</main>
39+
```
40+
2841
When a request is in flight, this will cause the `htmx-request` class to be added to the `#spinner`
2942
image. The image also has the `htmx-indicator` class on it, which defines an opacity transition
3043
that will show the spinner:

0 commit comments

Comments
 (0)