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

hx-on causes error when swapping #1413

Closed
johanhaleby opened this issue Apr 28, 2023 · 1 comment
Closed

hx-on causes error when swapping #1413

johanhaleby opened this issue Apr 28, 2023 · 1 comment

Comments

@johanhaleby
Copy link

I have this piece of html:

<div id="showIt"><!-- --></div>

<button
        id="someId"
        style="margin-bottom: 1rem;"
        hx-get="/my-app/stuff"
        hx-target="#showIt">
    Show it
</button>

/my-app/stuff returns this HTML:

<button hx-on="click: alert('ikk')">Close</button>

This works exactly like I want the first time I click on the button with id someId. But the second time, I essentially just want the second button to be re-rendered again. But instead, I see two buttons next to each other with the text "Close" and I get an error with HTMX:

image

@johanhaleby
Copy link
Author

@Renerick mentioned this on Discord:

I think there it should've been for ... in, not for ... of, -> https://github.com/bigskysoftware/htmx/blob/master/src/htmx.js#L924

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