Dhtmlx.confirm onTabClose event

Darya,

I have a similar issue. I presently us the below code to confirm that a user wants to close a document in a tab before allowing it to close.

tabBar.attachEvent(“onTabClose”, function (id) {
var r = confirm("Are you sure you want to close " + tabBar.getActiveTab() + “?”);
return r;
});

I would like to achieve the same thing with dhtmlx.confirm, but the modality of the control causes it to continue past the dhtmlx.confirm. Is there a way to change the modality or how would you achieve this?

Cheers,

Alex

You need always return false on tab close

tabBar.attachEvent("onTabClose", function (id) { var r = confirm("Are you sure you want to close " + tabBar.getActiveTab() + "?"); return false; });
And depending on result call removeTab manually

Darya,

I don’t think you understood my question.

Using confirm works perfectly fine, but dhtmlx.confirm does not. Execution continues beyond dhtmlx.confirm to the next line of code. It does not wait for the confirm to complete before continuing.

I would like an example of my code, but written using dhtml.confirm instead of confirm.

Cheers,

Alex

Try the next approach:

tabbar = new dhtmlXTabBar("a_tabbar", "top"); tabbar.setStyle("dhx_skyblue"); tabbar.setImagePath("../dhtmlxTabbar/codebase/imgs/"); tabbar.setSkinColors("white","#FFFACD"); tabbar.enableTabCloseButton(true); tabbar.addTab("tab1","Tab 1","100px"); tabbar.addTab("tab2","Tab 2","100px"); tabbar.addTab("tab3","Tab 3","100px"); tabbar.setTabActive("tab1"); tabbar.attachEvent("onTabClose", function(id){ dhtmlx.confirm("Do you want to close the tab?", function(result){ if (result == true) { tabbar.removeTab(id); } else { return false; } }); });