mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
tabs: don't change tab selection if panel does not contain item #279
This commit is contained in:
parent
47e9eb8ced
commit
5118f1982e
2 changed files with 5 additions and 4 deletions
|
@ -46,10 +46,10 @@ echo "Hello World!"
|
|||
| **groupId** | `default` | Arbitrary name of the group the tab view belongs to.<br/><br/>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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue