JQuery UI Tabs - replace tab and contents
Posted
by Tauren
on Stack Overflow
See other posts from Stack Overflow
or by Tauren
Published on 2010-04-03T23:43:57Z
Indexed on
2010/04/03
23:53 UTC
Read the original article
Hit count: 293
What is the best way to replace the currently selected tab and its contents? The content is dynamically generated with jquery, not loaded via a URL.
I need to do this from outside of any tab code or tab event handler (show, add, etc.). There is a link elsewhere on the page that should do the following when clicked:
- Change the tab's title
- Change the tab's className
- Clear out all elements of the tabcontent div
- Change the tabcontent div's className
- Generate new content inside the tabcontent div
Note that the only reference this link's click() handler has is to the JQuery tabs object ($Tabs). I can get the selected tab with $Tabs.tabs('option','selected')
. But how can I get a reference to the selected tab's tab and panel? Inside of a jquery tab handler (show, add, etc.), I have access to ui.tab
and ui.panel
, but is there a way to get them from a tabs option?
Would it be better to simply remove the currently selected tab and then add a new tab in the same index location? I'd have to put the code to generate the tab content into the add() handler then I suppose.
© Stack Overflow or respective owner