Reputation: 23
I'm using onsen ui for my app.
<ons-tabbar position="top" animation="fade" id="tabsLayout">
</ons-tabbar>
Is possible to add tab-item with javascript?
Upvotes: 2
Views: 825
Reputation: 3614
Yes, that works fine. Just append it to the element with the class name "tab-bar" and don't forget to run ons.compile()
on the element:
var $tab = $('<ons-tab page="home.html" label="Label" active="true"></ons-tab>');
$('.tab-bar').append($tab);
ons.compile($tab[0]);
I used jQuery to make creating the element a bit more easily. You can of course use document.createElement()
and el.appendChild()
instead if you aren't using jQuery.
Upvotes: 2