PDA

View Full Version : Prevent Tab removal



smokinguns
11 Jul 2009, 8:52 AM
Hey All,
I have the following code for creating a tab structure:


var tabs = new Ext.TabPanel({
renderTo:'tabs',
resizeTabs:true, // turn on tab resizing
minTabWidth: 115,
tabWidth:135,
enableTabScroll:true,
width:600,
height:0,
bodyCfg: { tag: 'center',
cls: 'x-panel-body',
html: '<p align="left"><b>Add new </b></p>' },
listeners: {
tabchange: function(tabPanel, tab) {
document.getElementById('output').innerHTML=tab.id;
},
remove: function(tabPanel, tab) {
res=confirm("sure ?")
if(!res)
return false;
}
},
defaults: {autoScroll:true},
plugins: new Ext.ux.TabCloseMenu()
});


The tabs can be removed because I have given that option. I want to prevent tab deletion if the user changes his mind. I want to confirm his choice before deleting the tab. But it doesnt seem to work. How do I achieve this

Animal
11 Jul 2009, 9:34 AM
THis has been covered many times. beforeclose handler, Ext.Msg.confirm, and explicitly remove the tab in the callback. Return false from the handler.