Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#10201 closed defect (invalid)

Programatically removing a tab in a tabcontainer does not work

Reported by: vorun Owned by:
Priority: high Milestone: tbd
Component: Dijit Version: 1.4.0b
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

The makeTab function is from the test_TabContainer.html page.

function makeTab()
{
var tc = dijit.byId("mainTabContainer");
var cp = new dijit.layout.ContentPane
({ 
title: 'Programmatically created tab ' + (progTabCounter++) , 
closable: true
});
cp.domNode.innerHTML = "I was created programmatically!";
tc.addChild(cp, 0);
}

I added this function to remove the current selectedChildWidget

function removeTab()
{
var tc = dijit.byId("mainTabContainer");
tc.removeChild(tc.selectedChildWidget);
}

Change History (3)

comment:1 Changed 10 years ago by bill

Component: GeneralDijit
Description: modified (diff)
Owner: anonymous deleted

You need to attach test cases to all your tickets using the "Attach File" button. Thanks.

comment:2 Changed 10 years ago by bill

Resolution: invalid
Status: newclosed

comment:3 Changed 7 years ago by tyfoo

I know this is 3 years in the past, but I was just having a similar problem (I think), and hopefully others who hit this page can benefit from this tidbit.

When you programmatically remove a child from the tab container, the child still exists in memory (if you do dijit.byId('tab-id'), you can see that it is still there).

For me, the error occurred when I tried to re-create the child that I had removed previously, since it still exists.

So instead of just removing it from the tab container, you have to both remove it and destroy the dijit object.

tc.removeChild(tc.getChildren()[0]);
dijit.byId('tab-id').destroy();

Hope this helps.

Note: See TracTickets for help on using tickets.