I'm using the tab close button as a delete button and would like to prompt the user before closing. This is the javascript I'm using.
function WebTab1_TabClosing(sender, eventArgs)
{
var part = sender._tab.findChild('txtPartNumber').value;
if (part != '') {
var okContinue = window.confirm('Are you sure you want to delete part ' + part + '?');
if (okContinue) {
eventArgs.set_cancel(false);
} else {
eventArgs.set_cancel(true);
}
The problem is that sender._tab gives the active tab and not the tab the close button was clicked on. How do you get the tab the close button was clicked on? Ideally, I'd like to enable the close button on the active tab and have it disabled for the other tabs but I can't figure that out either.
Thanks,
Stacey
Hi Stacey,
Thank you for posting on our forums!
You can obtain the current tab that is closing with help from the eventArgs argument. eventArgs.get_tabIndex() will return the index of the tab. You can use this with the WebTab's get_tabs() function and index into it like this:
sender.get_tabs()[eventArgs.get_tabIndex()];
For more information on this tabIndex property, please see the following information:
http://help.infragistics.com/NetAdvantage/ASPNET/2012.2/CLR4.0/?page=WebTab~Infragistics.Web.UI.TabItemCancelEventArgs~tabIndex.html
It is also possible to hide the close button on inactive tabs through a little CSS. Add the following CSS code to your page.
<style type="text/css"> span.igtab_THTab img.igtab_THClose { visibility: hidden; } span.igtab_THTabSel img.igtab_THClose { visibility: visible; }</style>
If you need further assistance with this, please let me know and I'll be glad to help.