Is there a way to reload the selected tab I know there is the .load() function. But it wants a tab index and I don't seem to see a way to grab the selected tabs id.
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
Download this Plugin for cookies:
http://plugins.jquery.com/cookie/
Insert jQuery cookie to your page
and add this :
In case anyone else stumbles upon this question and - like me - is using the tabs by jQuery EasyUI, Simen's answer above won't work. Rather, to refresh a tab, use:
Where
tt
is theid
of your tab group created viaI managed to get this to work but it now loads the first tab twice when it isn't active. If anyone has any more advice on this that would be much appreciated.
You can see above that the request is made twice to the server but the first request is successful so it cancels the second. Not sure if this is an issue or not..? But Im not being reassured by seeing it in the console
Simen did have the correct answer but this has now been deprecated since JQuery UI 1.9
http://jqueryui.com/upgrade-guide/1.9/#deprecated-selected-option-renamed-to-active
You now use 'active' instead of 'selected'
So the code will look like:
var current_index = $("#tabs").tabs("option","active"); $("#tabs").tabs('load',current_index);
Update: In jQuery 1.9, the
selected
option is renamed toactive
. See attomman's answer.To get the currently selected index, use the
tabs('option','selected')
function.E.g, if you have a button
#button
(and the#tabs
element is made into tabs) where you want to get the index, do the following:Here's a demo: http://jsfiddle.net/sVgAT/
To answer the question indicated by the title, in jQuery 1.8 and earlier, you would do:
And in jQuery 1.9 and later, you would do: