开发者

How to force 'select' event in jQuery Tabs if tab already selected?

开发者 https://www.devze.com 2023-01-27 14:58 出处:网络
The main issue is that if tab is already selected the \'select\' event doesn\'t fire if i set the same tab id again. The reason i required in this to update the content located in the tab.

The main issue is that if tab is already selected the 'select' event doesn't fire if i set the same tab id again. The reason i required in this to update the content located in the tab. I need a way to fire 'select' even if i specify already selected tab id.

In theory this should work Something like:

tabControl.tabs('select', -1);
tabControl.tabs('select', selectedTab);

but 'select' takes zero based index, so it doesn't reset tabs开发者_StackOverflow中文版 as desired and doesn't raise event again.

Any solution?


I wouldn't recommend selecting tab twice just because you need to reload its contents. Instead I solved same issue by calling the tabs() 'load' method instead of 'select'.

var selectedTab = tabControl.tabs('option', 'selected');
tabControl.tabs('load', selectedTab);


If you have the selected tab object (selectedTab), try to call the event directly with something like:

selectedTab.select();
0

精彩评论

暂无评论...
验证码 换一张
取 消