After upgrading from 3.5 to 3.6 there is an issue if there are "holes" in the numbering of quicktabs due to a hidden tab (no content). In these cases when switching tab hides the content and it stay hidden.
Settings to reproduce:
- Ajax: NO
- Hide empty tabs: YES
I have four tabs:
- Tab1 (get id 0 in hash)
- Tab2 (get id 1 in hash)
- Tab3 (get id 2 in hash), no content - will be hidden
- Tab4 (get id 3 in hash)
After clicking on one of the tabs the DOM looks like this:
<div id="quicktabs-container-quicktabs_tab" class="quicktabs_main quicktabs-style-zen">
<div id="quicktabs-tabpage-quicktabs_tab-0" class="quicktabs-tabpage quicktabs-hide">
<div id="quicktabs-tabpage-quicktabs_tab-1" class="quicktabs-tabpage quicktabs-hide">
<div id="quicktabs-tabpage-quicktabs_tab-3" class="quicktabs-tabpage quicktabs-hide">
</div>
Notice that all have the class "quicktabs-hide".
This doesn't happens if there isn't gaps in the id-values.
After reverting the changes from 3.5->3.6 it works again.
--- a/www/sites/all/modules/quicktabs/js/quicktabs.js
+++ b/www/sites/all/modules/quicktabs/js/quicktabs.js
@@ -57,11 +57,12 @@ Drupal.quicktabs.tab = function (el) {
this.tabIndex = el.myTabIndex;
var qtKey = 'qt_' + el.qt_name;
var i = 0;
- for (var i = 0; i < Drupal.settings.quicktabs[qtKey].tabs.length; i++) {
+ for (var key in Drupal.settings.quicktabs[qtKey].tabs) {
if (i == this.tabIndex) {
- this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[i];
- this.tabKey = i;
+ this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[key];
+ this.tabKey = key;
}
+ i++;
}
this.tabpage_id = 'quicktabs-tabpage-' + el.qt_name + '-' + this.tabKey;
this.container = $('#quicktabs-container-' + el.qt_name);
/Johan
Comments
Comment #1
denko_z commentedI confirm both the issue and workaround
Comment #2
shotokai commentedAttaching a patch (file) based on johan.wilfer patch (code) above.
Comment #3
shotokai commentedUpdating issue status so patch will be reviewed.
Comment #4
capellicThanks for the patch. Had this exact same problem. Applied. Works well.
Comment #5
cafuego commentedMe three, thank you.
Comment #6
fls commentedsame here. after applying the patch everything works fine.
Comment #7
fmb commentedWorked for me too, thank you shotokai.
Comment #8
philsward commentedAwesome! #3 works beautifully :-)
Comment #9
jaysonjaynes commented#3 worked for me as well. Thanks again, skotokai and johan.wilfer!
Comment #10
erykmynn commented#3 worked like a charm! -- pretty annoying update bug. Hopefully it gets wrapped in a new release.
Comment #11
drywall commentedWhat erykmynn just said in #10.
Comment #12
aasarava commented#3 works. Please commit!
Comment #13
supradhan commentedAwesome job. #3 works as charm.
Comment #14
deggertsen commentedThank you. #3 works.
Comment #15
nicxvan commentedAnother plus for #3
Can we commit this?
Comment #16
sillygwailoI can confirm that it works, using the patch at #3 on 3.6 fixes the issue of the
quicktabs-hidenot being removed on tabs that don't have a sequential ID.Comment #17
ultimateboy commentedThanks for the work on this all. Sorry it's taken so long to get this committed.
I've gone ahead and committed #3 to 7.x-3.x.
http://drupalcode.org/project/quicktabs.git/commit/aeeaaa94a2c580c140aa2...
Comment #18
cafuego commentedYay, thank you :-)
Comment #20
Sumit kumar commentedYaa Thanks #3 patch works fine.
Comment #21
charles1988 commentedThe patch #2 worked for me
Comment #22
sardis commentedReport from 2016 year. Patch #3 is still working, saving the people.