mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-16 14:17:00 +08:00
12 lines
339 B
JavaScript
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 };
|