I need to trigger a event when a specific horizontal tab has been focused. Probably it should be done implementing a the javascript hook but I can't figure out how. The only way I found is to modify directly horizontal-tabs.js putting this code in line 133, but for sure that is really a bad solution:

if (this.item.hasClass('horizontal-tab-button-3')) //do something

Comments

nils.destoop’s picture

Issue summary: View changes
Status: Active » Fixed

You can do this by adding your own javascript and use http://api.jquery.com/focus/ on the fieldset that represents the tab content.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ropic’s picture

Not working for me, i needed to overwrite the focus method and fire a custom event:

Drupal.horizontalTab.prototype.focus = function () {
    this.fieldset
      .removeClass('horizontal-tab-hidden')
      .siblings('fieldset.horizontal-tabs-pane')
        .each(function () {
          var tab = $(this).data('horizontalTab');
          tab.fieldset.addClass('horizontal-tab-hidden');
          tab.item.removeClass('selected');
        })
        .end()
      .siblings(':hidden.horizontal-tabs-active-tab')
        .val(this.fieldset.attr('id'));
    this.item.addClass('selected');
    // Mark the active tab for screen readers.
    $('#active-horizontal-tab').remove();
    this.link.append('<span id="active-horizontal-tab" class="element-invisible">' + Drupal.t('(active tab)') + '</span>');
    $(this.fieldset).trigger('tab:selected');
  }