mattelen / vue3-runtime-template

Vue component for compiling templates on the fly using a v-html like API
MIT License
47 stars 12 forks source link

Add optional callback function property "ready" for dynamic component… #7

Closed richardtallent closed 1 year ago

richardtallent commented 2 years ago

I'm using this component to render Vue components within HTML that is uses RevealJS to create a slideshow out of it. Unfortunately, RevealJS can only be initialized after the component has rendered into the DOM, and there's no event to hook into for that (at least that I could find).

So, this adds a prop called ready, which takes a callback function. When the dynamic component's loaded lifecycle event occurs, this callback function is fired, allowing the parent control to interact with the rendered DOM.

(I tried to make this an event first, but couldn't quite figure that one out.)

mattelen commented 2 years ago

Hi @richardtallent, appreciate the time you've spent contributing to the code. I am thinking that triggering an event would be the best way to achieve this, but you mentioned that you couldn't figure it out. Did you try running something like this.$emit('ready') in the mounted function?

mattelen commented 1 year ago

Closing due to staleness