Liveview and onBeforeElUpdated

Note that doing

onBeforeElUpdated(from, to){
  to.classList = from.classList
}

would copy the classlist of every patched element over. That might be not what you want since it might revert class changes made via liveview. You’d probably restrict the copying to certain elements only:

onBeforeElUpdated(from, to){
  if (from.classList.contains("before-update-copy-class")) {
    to.classList = from.classList
  }
}

I’ve also settled on that approach in a similar problem Liveview with Muuri grid (would phx-update="stop-ignore" make sense?).

1 Like