diff --git a/exampleSite/content/shortcodes/tabs.en.md b/exampleSite/content/shortcodes/tabs.en.md index 1d876075be..11c2f145d0 100644 --- a/exampleSite/content/shortcodes/tabs.en.md +++ b/exampleSite/content/shortcodes/tabs.en.md @@ -46,10 +46,10 @@ echo "Hello World!" | **groupId** | `default` | Arbitrary name of the group the tab view belongs to.

Tab views with the same **groupId** sychronize their selected tab. This sychronization applies to the whole site! | | _**<content>**_ | _<empty>_ | Arbitrary number of tabs defined with the `tab` sub-shortcode. | -{{% notice warning %}} +{{% notice note %}} When using tab views with different content sets, make sure to use a common `groupId` for equal sets of tabs but distinct `groupId` for different sets. -The tab selection is restored automatically based on the `groupId` and if it cannot find a tab item because it came from the `'default'` group on a different page then all tabs will be empty at first! +The tab selection is restored automatically based on the `groupId` and if it cannot find a tab item because it came from the `'default'` group on a different page then the first tab is selected instead. {{% /notice %}} ## Examples diff --git a/static/js/theme.js b/static/js/theme.js index 11fc55644a..58567bcd02 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -19,8 +19,9 @@ var psm; var pst; function switchTab(tabGroup, tabId) { - allTabItems = jQuery("[data-tab-group='"+tabGroup+"']"); - targetTabItems = jQuery("[data-tab-group='"+tabGroup+"'][data-tab-item='"+tabId+"']"); + var tabs = jQuery(".tab-panel").has("[data-tab-group='"+tabGroup+"'][data-tab-item='"+tabId+"']"); + var allTabItems = tabs.find("[data-tab-group='"+tabGroup+"']"); + var targetTabItems = tabs.find("[data-tab-group='"+tabGroup+"'][data-tab-item='"+tabId+"']"); // if event is undefined then switchTab was called from restoreTabSelection // so it's not a button event and we don't need to safe the selction or