Notice: The Monaca & Onsen UI Community Forum is shutting down.

For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.

Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.

Tabbar setActiveTab() and double 'init' event



  • Hello,

    Please help me with tabbar setActiveTab() method. I see folowing problems:

    1. If I have ons-page with ons-tabbar and first ons-tab have active attribute - setActiveTab() method doesn’t work during page initialization. If I use setActiveTab() in page init or show events - fist tab is active always (as I understand because first tab have active attribute). How I can change active tab before page displaying? Maybe if active tab option specified directly during initialization with setActiveTab() method you should ignore active attribute? I need active attribute because mostly time page displayed with first active tab by default and only sometime I need to open page with other active tab.

    2. If I remove active attribute from the first ons-tab and for each init event I use setActiveTab() (with tab index if specified or with first tab otherwise) - I see ‘init’ event twice for the first tab. Unfortunately these double init events crash Chosen and Select2 JavaScript libraries if tag selection control placed on the first page.


  • Onsen UI

    @Sergey I guess you tried like this, but I cannot see any repeated init event. Pen here.



  • @Fran-Diox Thanks for example.
    Yes I see that your example work as expected. Second tab activated even I added active attribute to the first tab. And no double init if I use setActivetab(0) with active attribute.
    But my project more complex and I will try to play with more complex Pen.
    Also is it possible because I use 2.0.3 version? I asked question regarding upgrade in this topic.


  • Onsen UI

    @Sergey I think Onsen UI 2.2.2 is available in Monaca, but make sure you have a look at the changelog while updating.