Hello,
I dynamically added 2 tabs by calling the
addTab function:
- $(function() {
- var tabTitle = $( "#tab_title" );
- var tabContent = $( "#tab_content" );
- var tabTemplate = "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close' role='presentation'>Remove Tab</span></li>";
- var tabCounter = 2;
- var tabs = $( "#tabs" ).tabs();
-
- function addTab(tabTitle, tabContent) {
- var label = tabTitle || "Tab " + tabCounter;
- var id = "tabs-" + tabCounter;
- var li = $( tabTemplate.replace( /#\{href\}/g, "#" + id ).replace( /#\{label\}/g, label ) );
- var tabContentHtml = tabContent || "Tab " + tabCounter + " content.";
-
- tabs.find( ".ui-tabs-nav" ).append( li );
- tabs.append( "<div id='" + id + "'><p>" + tabContentHtml + "</p></div>" );
- tabs.tabs( "refresh" );
- tabCounter++;
- }
How can i remove/close the dynamically added tabs? i tried the following approach, but it does not remove the tabs...
- // Remove the panel
- $( "#" + "tabs-2").remove();
- // Refresh the tabs widget
- tabs.tabs( "refresh" );
-
- // Remove the panel
- $( "#" + "tabs-3").remove();
- // Refresh the tabs widget
- tabs.tabs( "refresh" );