Skip to content

Issue with cloneNode with Phoenix LiveView #4514

Closed Answered by FabienHenon
FabienHenon asked this question in 5. Bugs
Discussion options

You must be logged in to vote

I figured out what was the problem and I was able to fix it.

For the cloneNode issue, here is the code to use for phoenix LiveView:

dom: {
    onBeforeElUpdated(from, to) {
      if (from._x_marker) {
        Alpine.cloneNode(from, to);
      }
    },
  },

cloneNode is called on update for any element handled by Alpine. Not only root elements.
This way, children of a root element being updated will be initialized by Alpine (solves my class problem).


The other issue was with template nodes being updated (their created elements were being removed from the DOM).
The issue is actually not directly related to template nodes, but to the directives that create/clone elements (like x-for, x-if, x…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by FabienHenon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant