-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
hx-vals is "global" and cannot be "disinherited" #1119
Comments
I can confirm the same bug in my system. |
I found a workaround using hx-params="not ". |
I have the same issue. Hope there will be some kind of fix for this. |
Another bump here while working on aio-libs/aiomonitor#371... |
- htmx does not allow disinheriting `hx-vals` attribute... :( (bigskysoftware/htmx#1119)
In my particular case, i had a piece of child template loaded from a div on "load" as shown below. My case might not be fit for yours, but it might give a clue for appropriate solution: <!-- loader parent -->
<div id="questionview"
hx-trigger="load"
hx-target="this"
hx-swap="innerHTML"
hx-post="/game/question/random"
hx-vals='{{ hxVals | tojson }}'></div> <!-- child template -->
...
<div class="choice"
hx-post="/game/answer/save"
hx-vals='{{ vals | tojson }}'
hx-trigger="click once"
hx-target="#choices"
hx-swap="outerHTML">{{ choice.body }}</div> and this results in something like: <div id="questionview ... >
...
<div class="choice" ... />
</div> The result would then inherit the whole hxVals from the questionview alongside the vals. I solved the issue by simply moving the caller into a child div of questionview, completely overwriting it on load by setting hx-swap="outerHTML" as shown below. I still got the same result but got rid of hx-vals inherited from parent questionview. <!-- loader parent -->
<div id="questionview">
<div hx-trigger="load"
hx-target="this"
hx-swap="outerHTML"
hx-post="/game/question/random"
hx-vals='{{ hxVals | tojson }}'></div>
</div> |
This is a problem for us too. We have a dropzone (parent) and within it a button that toggles and populates a sidebar with candidates (child). It breaks the child interaction. On the parent dropzone we need to access a nested event attribute that is not present in the event during the child interaction. The child interaction should not even try to access it but we can't disable that. |
having the same issue here. Caught me by surprise, I thought |
That really helps. Thanks. Also it's possible to use comma separated list for all inherited values like |
Still an issue, bump |
I have the same issue, bump |
Eek.. I burned a couple of hours on this. |
this is still a problem... I am having this issue with hx-include, I am fixing this with an extension. I guess you can extend this for It only support My use case is to enable server side form input validations
usage:
|
When you have defined hx-vals there is no way to avoid submitting ALL values inherited from parent nodes (actually the whole page).
I think hx-disinherit should work in the following case, but it's not. Both size and color are submitted.
I tried both hx-disinherit="hx-vals" and hx-disinherit="*" but this dis-inheritance is not working.
If you also try hx-vals="unset" on a child all values are deleted, even from the parent nodes.
It seems htmx uses a "global" vals variable to set / unset / change values, but I think this is a strange behavior and excludes many use cases with a page with many requests and different values per request.
The text was updated successfully, but these errors were encountered: