Wait for #commento to be loaded before reinit
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2a3c7a3567
commit
1a072203a8
@ -1,8 +1,9 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import { tick } from 'svelte';
|
||||||
|
|
||||||
export let pageId = null;
|
export let pageId = null;
|
||||||
|
|
||||||
$: {
|
async function changePageId(pageId) {
|
||||||
if (pageId) {
|
|
||||||
if (typeof window !== 'undefined' && !window.commento) {
|
if (typeof window !== 'undefined' && !window.commento) {
|
||||||
// init empty object so commento.js script extends this with global functions
|
// init empty object so commento.js script extends this with global functions
|
||||||
window.commento = { };
|
window.commento = { };
|
||||||
@ -19,11 +20,17 @@
|
|||||||
}
|
}
|
||||||
document.getElementsByTagName('head')[0].appendChild(script)
|
document.getElementsByTagName('head')[0].appendChild(script)
|
||||||
} else if (typeof window !== 'undefined' && window.commento) {
|
} else if (typeof window !== 'undefined' && window.commento) {
|
||||||
|
await tick();
|
||||||
window.commento.reInit({
|
window.commento.reInit({
|
||||||
pageId: pageId,
|
pageId: pageId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: {
|
||||||
|
if (pageId) {
|
||||||
|
changePageId(pageId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user