[tabBar] onTabClose not fired when use removeTab()

Hi guys,
I noticed that when i use the api to close a tab with this method removeTab() the “onTabClose” event doesn’t fire.
Personally i think it may be logical if the event fires when a tab is removed because that means it is closed.
If this is not possible why not make a method that enables us to trigger events.
Triggering events will be awesome and helpful.
I know that i can make a function and call it whenever i need but to my humble opinion i think triggering events is better.

Can you provide your event code snippet?

Here we go, i made a little sample just to show the behavior that i talked about.
tabbar_close_event_bug.rar (518 KB)

So if you close the tab using the close button in the tab the “onTabClose” event will fire.
But if you use a button from the toolbar to close a tab, which use the api “removeTab()” method, then the “onTabClose” will not fire.

I see…
So, in this case you don’t close the tab - you really remove it without closing.
You can by toolbar button to call custom function, i.e.:
funtion whenMyTabIsClosed(){
function myCustomOnTabCloseEventHandlerReaction(){
// custom onTabClose function

This what i said in my first post, doing that is going to mess the code a little bit.
The question is : why don’t you then give the possibility to close a tab using the api ?
It would be awesome if we have a method closeTab().
It is that or the onCloseTab event gets triggered when a tab is removed because that is basically closing it too.


  1. remove tab and close tab are the same things, just names (removeTab and onTabClose) should be corrected a bit (in a future version probably)

  2. event usually fired when you can’t locate some action from script (response to user action), when you call removeTab manualy - you know when action happen, when user click [x] button on tab - you have event


removeTab => removeTab
userClick => if (callEvent(“onTabClose”,[tabId]) == true) removeTab

Ok, but then why when i use the api “setTabActive()” the events “onTabClick” and “onSelect” get fired ?
This is contradictory to what you said in the second point.

historically happened :slight_smile:

setTabActive have 2nd param, set to false to skip event (true by default)