https://htmx.org logo
I have a question on how people are dealing with ...
# htmx-general
p
I have a question on how people are dealing with "JavaScript enhanced" elements on the page that get swapped? For example, I have a date picker using the flatpickr library in a form that is swapped when a new date is picked because there might be form errors. When the response arrives, I initialize the date picker from the response again via
htmx.onLoad()
, but there is a noticiable, visible change happening. I have simulated this at https://codepen.io/wimdeblauwe/pen/eYrwZgv for those that want to have a look. Just select a different date, and you will notice the flash. Interestingly,, I had to do some funky stuff to simulate it with demo.htmx.org, because flatpickr already initialized the date picker in the
<template>
that simulated the server response. Is there a possibility to temporarily mount something in the dom, non-visible and only swap after some callback was called where I could run the flatpickr initialization code to avoid that flicker?