Goal
Using the Hotwire, show how to setup a basic implementation of a modal with a form.
We'll break this down into talking about the c...
For further actions, you may consider blocking this person and/or reporting abuse
I don't like the fact of render edit partial on each iteration :/
Yep...that could likely be refactored to only put in one edit modal for entire page as an optimization
I've fine tuned this a bit to only edit one modal - could likely go further and make it one modal skeleton/post-modal stimulus controller instance for entire page if desired. Let me know what you think - gitlab.com/doug.stull/turbo_modal
I've further refactored it now to only render a modal skeleton once and utilize that for both
newandeditand updated this post - thanks for the nudge in a better direction!Do you know how we can run some JS when form appends? I'm using selectize, the first time works with turbo:loads, but not then because turbo just fires when the history changes :/
I donβt know how...yet. I had same issue with wanting to trigger showing the modal when it was finished rendering. In my case I hacked it with a 200ms timeout in the post-modal controller. Maybe someone will come along with an a solution.
I've updated the code used in this post with the latest release of turbo. I had to change how things loaded a bit and rely on turbo include tag to load turbo correctly. Webpack loading was having issues with any update of turbo-rails past 0.5.3.
Latest commit shows the updates gitlab.com/doug.stull/turbo_modal/...