Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Raffaele Gambelli on Aug 12, 2009 01:46
open dhtmlx forum
Tab Close Button doesn't work

Hi all,

I'm trying to add close button on my tabs and I've noticed some strange behaviour not corresponding to the API reference.

1) I've implemented the tabbar.setOnTabClose() to handle tab closure event, but in my app, I have a special tab that should never close and so, in this case, in the setOnCloseFunction, if user try to close my special tab, function should return false to skip tab closure, right? API reference says that.

Unfortunately, even if I return false, I cannot avoid the tab closure as I expected.

2) Other issue, as I said, I have a special tab that never close, and so, I'd like to not show on it the close icon, avoiding tab closure for only that tab. As reported on documentation about the enableTabCloseButton method:

"....mode will be applied to the tabs created AFTER command"

And so, I tried to call enableTabCloseButton method, after special tab creation, but this generated the following javascript error:

tab.childNodes[2].childNodes[this._TabCloseButton ? 1 : 0] is undefined
dhtmlxtabbar.js (riga 1904)

Any hint about close button correct usage?
Thanks in advance and best regards

Raffaele
Answer posted by Alex (support) on Aug 12, 2009 03:12

Hello, 

the onTabClose event doesn't allow to block closing. In order to enable this feature you should make a small modification in the dhtmlxtabbar.js:

please locate line

self.callEvent("onTabClose",[id]);

and replace it with 

if(self.callEvent("onTabClose",[id]))

Answer posted by alvaro on Oct 14, 2009 10:39
Hi,
Exactly the same problem I am asked, but I would not change the js file. Is there any other solution without changing the js file?

Thank you.
A greeting.
Answer posted by Raffaele Gambelli on Oct 15, 2009 00:30
Hi Alvaro,

I'm also didn't changed js sources as suggested...

Here it is my workaround:

I've added an html image near tab label and added an onclick on it that calls the tab closure dhtmlx method.

In this way, by code, I'm able to decide for each tab if put close action or not.
The only problem in this approach is that if you have active focus on tab A and you click on close button on tab B, the first click take you to tab B and so it need a second click to effectively close tab B.

Hope this can help you,
best regards