Skip to content

Instantly share code, notes, and snippets.

@calebporzio
Last active August 29, 2022 21:20
Show Gist options
  • Save calebporzio/20cf74af4a015644c7bef5166cffd86c to your computer and use it in GitHub Desktop.
Save calebporzio/20cf74af4a015644c7bef5166cffd86c to your computer and use it in GitHub Desktop.
<script data-turbo-eval="false">
document.addEventListener('turbo:before-render', () => {
let permanents = document.querySelectorAll('[data-turbo-permanent]')
let undos = Array.from(permanents).map(el => {
el._x_ignore = true
return () => {
delete el._x_ignore
}
})
document.addEventListener('turbo:render', function handler() {
while(undos.length) undos.shift()()
document.removeEventListener('turbo:render', handler)
})
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment