Skip to content

hx-disabled-elt documentation  #3081

Open
@mdolk

Description

The current hx-disabled-elt documentation says the following

find which will find the first child descendant element that matches the given CSS selector

It then gives the following example

Here is an example that disables buttons and text input fields of a particular form during the request:

<form hx-post="/example" hx-disabled-elt="find input[type='text'], find button">
    <input type="text" placeholder="Type here...">
    <button type="submit">Send</button>
</form>

It should be noted that only the first text input field is disabled which is somewhat surprising when you have multiple in your form! I think this could be made clearer :-)

I think a less contrived example for disabling multiple input fields is using fieldsets.

<form hx-post="/example" hx-disabled-elt="find fieldset">
    <fieldset>
        <input type="text" placeholder="Type here...">
        <input type="text" placeholder="More input here...">
        <button type="submit">Send</button>
    </fieldset>
</form>

Cheers!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions