Skip to content

Allow this to be used in hx-trigger #3399

@fifonik

Description

@fifonik

Feature request:

I'd like the form is submitted on some events on its children. I can do this right now as:

<form id="form1" hx-post="/test?1" hx-swap="none" hx-trigger="change from:#form1 input">
	<input type="checkbox" name="p_checkbox" id="checkbox_1" value="1" /><label for="checkbox_1"> One</label>
	<input type="checkbox" name="p_checkbox" id="checkbox_2" value="2" /><label for="checkbox_2"> Two</label>
</form>

<form id="form2" hx-post="/test?2" hx-swap="none" hx-trigger="change from:#form2 input">
	<input type="checkbox" name="p_checkbox" id="checkbox_3" value="3" /><label for="checkbox_3"> Three</label>
	<input type="checkbox" name="p_checkbox" id="checkbox_4" value="4" /><label for="checkbox_4"> Four</label>
</form>

However, I do not like the idea that I have to introduce and use the form IDs just for mentioning elements inside the form (this is making the automatically generated content of such forms harder to read)
So, I'd prefer something simpler, for example: change from:this input -- where this is used for mentioning the element itself as in hx-target.
Another option that I think should be fine: change from:findAll input

Thanks.

P.S. The change from:find input does not work as it only assign event listener to single input (the first checkbox in the above example).
P.P.S. The change from:closest (form input) does not work as well and I do not understand why as based on ur manual closest should match itself.

Metadata

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