How to create a component instance dynamically?
<head>
...
<script src="https://cubbles.world/sandbox/cubx.core.rte@3.0.0-SNAPSHOT/webcomponents/custom-elements-es5-adapter.js"></script>
<script src="https://cubbles.world/sandbox/cubx.core.rte@3.0.0-SNAPSHOT/webcomponents/webcomponents-lite.js"></script>
<script>
// 1. You should add the dependency of the desired component to the rootDependencies
window.cubx = {
"CRCInit": {
"rootDependencies": [
{
"webpackageId": "com.incowia.basic-html-components@2.0.0",
"artifactId": "cubx-textarea"
}
]
}
}
</script>
<script src="https://cubbles.world/sandbox/cubx.core.rte@3.0.0-SNAPSHOT/crc-loader/js/main.js" data-crcinit-loadcif="true"></script>
</head>
<body>
...
<script>
// 2. Create the component using the document API method createElement()
var cubxTextArea = document.createElement('cubx-textarea');
// 3. Append the component to the Cubbles container
document.body.appendChild(cubxTextArea);
</script>
</body>PreviousHow to manually resolve dependency conflicts?NextHow to render HTML Markup coming from input slot?
Last updated