public clicktoadd(e) {
// give the item as item model with header and content property
var items = { header: 'NewHeader', content: 'NewContentAdded' };
this.acrdnInstance.addItem(items); // add the item using addItem
} |
<ejs-button id="addBtnElem" content="click to add"></ejs-button>
<ejs-accordion id="defaultAccordion">
<e-accordion-accordionitems>
//...
</e-accordion-accordionitems>
</ejs-accordion>
<script>
document.getElementById("addBtnElem").addEventListener('click', function () {
var accordion, items = { header: 'NewHeader', content: 'NewContentAdded' }; // give the item as item model with header and content property
//Recommended way to get instance of EJ2 component.
accordion = ej.base.getComponent(document.getElementById("defaultAccordion"), "accordion");
accordion.addItem(items); // add the item using addItem
//or
//Direct access
//document.getElementById("defaultAccordion").ej2_instances[0].addItem(items);
});
</script> |