Created
April 11, 2025 20:43
-
-
Save oliveira-andre/9134ad35db2d4975dabde0e117635dad to your computer and use it in GitHub Desktop.
Turbo Morph compatibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller } from "@hotwired/stimulus"; | |
export default extends Controller { | |
connect() { | |
this.reconnect = this.reconnect.bind(this); | |
window.addEventListener('turbo:morph', this.reconnect); | |
myLibrary.create(); | |
} | |
disconnect() { | |
window.removeEventListener('turbo:morph', this.reconnect); | |
} | |
reconnect() { | |
myLibrary.destroy(); | |
myLibrary.create(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment