i have a quicktab with three view's blocks. One of them is sometimes empty. When this happens, the tab functionality is somehow broken and when the user clicks on the tabs the content area remains white.
i thought it could be related to https://drupal.org/node/766924, but actually in my case the tab is correctly not shown for the empty block.

I'll try to come back with a patch for this issue.

Comments

joey-santiago’s picture

The problem happens only when the empty tab is not the last one. It happens then that

Drupal.settings.quicktabs[qtKey].tabs.length

is undefined, so this loop in JS doesn't work:

for (var i = 0; i < Drupal.settings.quicktabs[qtKey].tabs.length; i++) {
    console.log(i);
    console.log(this.tabIndex);
    if (i == this.tabIndex) {
      this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[i];
      this.tabKey = i;
    }
  }

haven't found a way to patch that yet. it's bugging me a lot.

joey-santiago’s picture

I think the problem is that when the tabs are initialized in JS, the ids of the elements are not synchronized with the php information sent to Drupal.settings.quicktabs:

Drupal.quicktabs.prepare = function(el) {
  // el.id format: "quicktabs-$name"
  var qt_name = Drupal.quicktabs.getQTName(el);
  var $ul = $(el).find('ul.quicktabs-tabs:first');
  $ul.find('li a').each(function(i, element){
    element.myTabIndex = i;
    element.qt_name = qt_name;
    var tab = new Drupal.quicktabs.tab(element);
    var parent_li = $(element).parents('li').get(0);
    if ($(parent_li).hasClass('active')) {
      $(element).addClass('quicktabs-loaded');
    }
    $(element).once(function() {$(this).bind('click', {tab: tab}, Drupal.quicktabs.clickHandler);});
  });
}

this sets tabIndexes based on the html created, but the object Drupal.settings.quicktabs has different indexes set on the configuration of the tabs so having the empty placeholders for the empty tabs.

joey-santiago’s picture

Here's a patch.

jncruces’s picture

Thanks!!

Your patch works.

Only the change of tab now reload the page, bug i have not time to correct it.

Edit:
I found this issue related that not produces a page reload:
https://www.drupal.org/node/2108935

smustgrave’s picture

Status: Active » Closed (outdated)

With D7 EOL approaching in a month I'm starting to triage the D7 side of quicktabs queue. This doesn't appear to have any code so believe this may not make it, sorry! Thanks though!

If still an issue or needed for 4.0.x (latest branch) feel free to reopen