Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: OOB attribute update support (at least for disabled/read-only) #1491

Open
ehenighan opened this issue Jun 13, 2023 · 0 comments
Open

Comments

@ehenighan
Copy link
Contributor

Use case: multiple actions on your page can swap in a form in place of some view component. Ideally you want clicking on one of them to prevent clicking the others while the form is open, so you only have one form on the page at a time. A bit like the disable-element extension, only affecting an arbitrary number of components and persisted beyond the end of the request.

Something like the hx-swap-oob attribute, but e.g. hx-set-attribute-oob, where the value is e.g.:

hx-set-attribute-oob="[css-selector]:add:disabled"
hx-set-attribute-oob="[css-selector]:add:some-other-attr=some-val"
hx-set-attribute-oob="[css-selector]:remove:disabled"

At the moment you can kind of achieve this by removing the whole element with hx-swap and then restoring it later when you re-render the wider page after form submission, but it would be nice to be able to (at least) set other things disabled or read-only out of band, rather than having to rebuild all the elements from fragments and include them as swaps.

(Unsure about this)
Might be safer to just permit this for disabled/read-only rather than for arbitrary attributes? I don't have a strong feeling for which would be preferable, really

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant