Tabbar setActiveTab() and double 'init' event
-
Hello,
Please help me with tabbar setActiveTab() method. I see folowing problems:
-
If I have
ons-page
withons-tabbar
and firstons-tab
haveactive
attribute -setActiveTab()
method doesn’t work during page initialization. If I usesetActiveTab()
in pageinit
orshow
events - fist tab is active always (as I understand because first tab haveactive
attribute). How I can change active tab before page displaying? Maybe if active tab option specified directly during initialization withsetActiveTab()
method you should ignoreactive
attribute? I needactive
attribute because mostly time page displayed with first active tab by default and only sometime I need to open page with other active tab. -
If I remove
active
attribute from the firstons-tab
and for eachinit
event I usesetActiveTab()
(with tab index if specified or with first tab otherwise) - I see ‘init’ event twice for the first tab. Unfortunately these doubleinit
events crash Chosen and Select2 JavaScript libraries if tag selection control placed on the first page.
-
-
-
@Fran-Diox Thanks for example.
Yes I see that your example work as expected. Second tab activated even I addedactive
attribute to the first tab. And no doubleinit
if I usesetActivetab(0)
withactive
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.
-
@Sergey I think Onsen UI 2.2.2 is available in Monaca, but make sure you have a look at the changelog while updating.