How to create a component instance dynamically?
To create, and then, add a component instance dynamically you should:
Add the dependency of the desired component to the
rootDependencies
Create the component using the document API method
createElement()
Append the component to the Cubbles container (by default the
body
, otherwise the element having thecubx-core-crc
attribute)
The code below presents this process for adding a new cubx-textarea
to an existing app:
Use document.createElement: Although you may want to append the component using the
innerHTML
property of a container, you should use thedocument.createElement()
method for everything to work properly.
Last updated