From 8e70080cf7827f9c6f4adaccc4fe67a8f96084e0 Mon Sep 17 00:00:00 2001 From: phamt Date: Mon, 11 Oct 2010 20:35:04 +0000 Subject: [PATCH] Fix bug where tab would not close when you select a new group. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7813 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/ui.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/xCAT-UI/js/ui.js b/xCAT-UI/js/ui.js index a9d1b19fa..85498d6cc 100644 --- a/xCAT-UI/js/ui.js +++ b/xCAT-UI/js/ui.js @@ -36,16 +36,6 @@ Tab.prototype.init = function() { // Hide tab this.tab.hide(); - - // Close tab when close button is clicked - $("#" + this.tabId + " span.tab-close").live("click", function() { - var index = $('li', tabs).index($(this).parent()); - - // Do not remove first tab - if (index != 0) { - tabs.tabs('remove', index); - } - }); }; /** @@ -86,6 +76,21 @@ Tab.prototype.add = function(newTabId, newTabName, newTabCont, closeable) { if (closeable) { var header = this.tab.find('ul.ui-tabs-nav a[href="#' + newTabId +'"]').parent(); header.append(''); + + // Get this tab + var tabs = this.tab; + var tabLink = 'a[href="\#' + newTabId + '"]'; + var thisTab = $(tabLink, tabs).parent(); + + // Close tab when close button is clicked + thisTab.find('span.tab-close').bind('click', function(event) { + var tabIndex = ($('li', tabs).index(thisTab)); + + // Do not remove first tab + if (tabIndex != 0) { + tabs.tabs('remove', tabIndex); + } + }); } };