Replies: 4 comments 2 replies
-
Not only |
Beta Was this translation helpful? Give feedback.
-
Hi @calebporzio first of all, thanks for the great work on alpinejs. I assumed this was resolved in 3.2.0 as mentioned Please let me know if I missed something |
Beta Was this translation helpful? Give feedback.
-
3.2.0 exposes the <div x-html="content()" x-init="$nextTick(() => Alpine.initTree($el.firstElementChild))"></div> But it's probably something that should go into a PR. But for now that should work. Here's a fork of your demo: https://codepen.io/KevinBatdorf/pen/MWmWVEN?editors=1010 |
Beta Was this translation helpful? Give feedback.
-
Not sure if this is well known, but the thing here is that while x-for inserts the elements, the mutationobserver is paused, so if the element contains alpine code, it is not evaluated I submitted a PR #1697 - as simple as wrapping x-html handler in a nextTick by default. would love to hear some feedback if you guys think this could be a viable solution |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Elements with a click event that are dynamically rendered using
x-html
isn't triggredSteps to reproduce
I prepared 2 codepens to reproduce it:
v2 - https://codepen.io/dgigafox/pen/QWpXNyZ
v3 - https://codepen.io/dgigafox/pen/abJgZPK
Here is the html layout that both codepen are using:
Actual results
In v2, clicking on the Red, Orange, Yellow buttons changes the
activeColor
which is displayed at the bottom. Those buttons are dynamically rendered viax-html
directive. Although in v3, with the same layout, click events aren't triggered - only theNo color
button is triggered since it is already present from the start.Expected result
The corresponding color of the button should be set when the click event is triggered just like in v2 and should work as well in v3
Beta Was this translation helpful? Give feedback.
All reactions