scinote-web/app/javascript/packs/vue/helpers/turbolinks.js
2023-11-09 19:22:50 +01:00

12 lines
339 B
JavaScript

function mountWithTurbolinks(app, target) {
const originalHtml = document.querySelector(target).innerHTML;
document.addEventListener('turbolinks:before-cache', () => {
app.unmount();
document.querySelector(target).innerHTML = originalHtml;
}, { once: true });
return app.mount(target);
}
export { mountWithTurbolinks };