You are correct that the tabs retain their old index values ββwhen they change, which leads to unexpected behavior when you try to delete it. You can force it to update indexes by reinitializing tabs before deleting, for example:
$('#tabs').tabs('destroy').tabs(); $('#tabs').tabs('remove', 2);
This works because indexes are generated when tabs are configured based on the positions of li elements in the DOM. When you move tabs, li positions are updated in the DOM, even if their index values ββdo not change in the tab plugin.
Of course, if you have a very complicated setup, this can have negative performance implications, in which case you could figure out a different way to update tab indices, or you could maintain an array that maps source indices to current indices.
source share