We are using quicktab 7.3 version. In one quicktab instance, we have 13 tabs, and we need to hide empty blocks. The render of 'quicktabs' doesn't work for this instance, while the other two render 'accordion' and 'ui_tabs' are working fine.
I figured this issue happens because the way of getting tab index is depending on the order of tab link inside the tab link group.
See js/quicktabs.js
$ul.find('li a').each(function(i, element){
element.myTabIndex = i;
}
When we hide the empty tabs, this element.myTabIndex will be wrong. For example, tab0 tab1,tab3 has content, but tab2 doesn't have content. Then for tab3, the table index should be 3, but the current code will get 2 for tab3, because tab2 link has been removed in html structure.
Attached patch works for me.
Comment | File | Size | Author |
---|---|---|---|
#20 | quicktabs-2396031-fix_empty_tabs.patch | 1.76 KB | daniel_j |
Comments
Comment #1
smiletrl CreditAttribution: smiletrl commentedComment #2
jazzitup CreditAttribution: jazzitup commentedI came across the same issue, tested it and I can confirm the patch fixes the flaw.
Comment #3
gunosov CreditAttribution: gunosov commentedWorks for me. Thanks!
Comment #4
pramodganore CreditAttribution: pramodganore commentedCan confirm this works.
FYI: I was using the Phpstorm git patch apply and it does not delete some code and sticks the following code in wrong location.
this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[this.tabIndex];
this.tabpage_id = 'quicktabs-tabpage-' + el.qt_name + '-' + this.tabKey;
I am glad i do a cross check on my patches, this saved me more dev time.
Comment #5
larkydoo CreditAttribution: larkydoo as a volunteer commentedI wasn't able to get the patch to apply using the patch command. It was unable to find the third Hunk:
- var i = 0;
- for (var key in Drupal.settings.quicktabs[qtKey].tabs) {
- if (i == this.tabIndex) {
- this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[key];
- this.tabKey = key;
- }
- i++;
- }
When I looked at the code, it was actually the following:
var i = 0;
for (var i = 0; i < Drupal.settings.quicktabs[qtKey].tabs.length; i++) {
if (i == this.tabIndex) {
this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[i];
this.tabKey = i;
}
}
I'm attaching a patch that should address this issue. It has not been tested, so use at your own risk.
I manually edited the quicktabs.js file using the code in the patch, and it works mahvellously.
Thanks!
Laurie
Comment #7
larkydoo CreditAttribution: larkydoo as a volunteer commentedRE: Patch failure: My patch is designed to work with quicktabs-7.x-3.6; the original patch should work with quicktabs-7.x-3.x-dev.
Comment #8
jazzitup CreditAttribution: jazzitup commented@larkydoo: "Make patches against the -dev version because it is the latest code."
Please always strictly follow the manual: https://www.drupal.org/node/707484
Comment #9
oscaral@larkydoo solution works for us for 7.x-3.6 (thanks :) )
Comment #10
martinwrightinfo CreditAttribution: martinwrightinfo commentedI've tested the patch above (#9) and can confirm that this fixes the problem in 7.x-3.6.
Comment #11
fdefeyter@gmail.com CreditAttribution: fdefeyter@gmail.com commentedI confirm this patch works as well. Why isn't it commited? thx
Comment #12
jazzitup CreditAttribution: jazzitup commentedComment #14
alex_gred CreditAttribution: alex_gred commented@smiletrl solution working fine.
Thanks!
Comment #15
gajanannehul CreditAttribution: gajanannehul as a volunteer and at Clarion Technologies commented#9 is working fine.
Thanks!!!
Comment #16
markdcI can confirm #9 is working. Thank you.
Comment #17
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedThe patch did not apply correctly
patch -p1 < patchfile
patching file js/quicktabs.js
Hunk #1 succeeded at 25 with fuzz 2 (offset 3 lines).
Hunk #2 succeeded at 44 (offset 5 lines).
Hunk #3 FAILED at 69.
1 out of 3 hunks FAILED -- saving rejects to file js/quicktabs.js.rej
> test/sites/test/modules/quicktabs$ more js/*rej
--- js/quicktabs.js
+++ js/quicktabs.js
@@ -69,13 +82,9 @@
this.element = 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++) {
- if (i == this.tabIndex) {
- this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[i];
- this.tabKey = i;
- }
- }
+ this.tabKey = this.tabIndex;
+ this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[this.tabIndex];
+
this.tabpage_id = 'quicktabs-tabpage-' + el.qt_name + '-' + this.tabKey;
this.container = $('#quicktabs-container-' + el.qt_name);
this.tabpage = this.container.find('#' + this.tabpage_id);
Comment #18
smiletrl CreditAttribution: smiletrl commentedYou should apply the (original) patch against the latest dev version.
If you fail any patch apply, you can manually edit your code using the change from existing patches, and create a new patch for the change.
Comment #19
4kant CreditAttribution: 4kant commentedI too can confirm #9 works for me.
Thanks!
Comment #20
daniel_j CreditAttribution: daniel_j commentedRe-rolling #9 to apply to latest dev commit.
Comment #21
daniel_j CreditAttribution: daniel_j commentedComment #22
Sebastian Hagens#20 works for me