Is it possible to create Onsen UI elements dynamically using JavaScript? The official documentation says nothing about it.
You can create dynamically Onsen UUI elements by using ons._util.createElement() function. It takes, in input, the HTML code you want to generate. For example:
var button = ons._util.createElement("<ons-button></ons-button>");
document.body.appendChild(button);
It will create a ons-button element, and append it to the body.
EDIT
You can also create it in an alternative way:
var div = document.createElement('div');
div.innerHTML = '<ons-button></ons-button>'
document.body.appendChild(div);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With