Skip to content

htmx.process doesn't seem to process #3421

@Coysh

Description

@Coysh

I'm using htmx through the sprig implementation for Craft CMS. I love it.

I'm using javascript to dynamically inject some <input sprig type="checkbox" beneath some existing checkboxes. The initial <input trigger a htmx call when clicked - but the injected ones do not.

htmx.ajax("POST", "XX", {
	values: {},
	target: container,
	swap: "innerHTML",
}).then(() => {
	const $htmxComponents = document.querySelectorAll('.sprig-component');

	if($htmxComponents) {
		$htmxComponents.forEach($htmxComponent => {
			htmx.process($htmxComponent);
		});
	}
});

So my initial htmx load is:
<input sprig type="checkbox" value="1" name="location[]">

And when the above htmx is loaded is then looks like

<input sprig type="checkbox" value="1" name="location[]">
<input sprig type="checkbox" value="2" name="location[]">

Clicking the first <input works, but the second isn't triggering anything.

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