mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 15:57:57 +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! |
|
| **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. |
|
| _**<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.
|
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 %}}
|
{{% /notice %}}
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
|
@ -19,8 +19,9 @@ var psm;
|
||||||
var pst;
|
var pst;
|
||||||
|
|
||||||
function switchTab(tabGroup, tabId) {
|
function switchTab(tabGroup, tabId) {
|
||||||
allTabItems = jQuery("[data-tab-group='"+tabGroup+"']");
|
var tabs = jQuery(".tab-panel").has("[data-tab-group='"+tabGroup+"'][data-tab-item='"+tabId+"']");
|
||||||
targetTabItems = jQuery("[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
|
// 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
|
// so it's not a button event and we don't need to safe the selction or
|
||||||
|
|
Loading…
Reference in a new issue