Skip to content

Instantly share code, notes, and snippets.

@cafuego
Created December 23, 2013 00:56
Show Gist options
  • Save cafuego/8090362 to your computer and use it in GitHub Desktop.
Save cafuego/8090362 to your computer and use it in GitHub Desktop.
Re-open a quicktab after clicking a link under said tab (for a quicktabs view)
(function ($) {
Drupal.qtpersist = Drupal.qtpersist || {};
Drupal.behaviors.qtpersist = {
attach: function (context, settings) {
$.extend(true, Drupal.settings, settings);
$('.quicktabs-wrapper', context).once(function(){
Drupal.qtpersist.prepare(this);
});
}
}
// Setting up the inital behaviours
Drupal.qtpersist.prepare = function(el) {
// el.id format: "quicktabs-$name"
var qt_name = Drupal.quicktabs.getQTName(el);
var $main = $(el).find('div.quicktabs_main:first');
$main.find('div.quicktabs-tabpage').each(function(i, element){
element.myTabIndex = i;
element.qt_name = qt_name;
$(element).find('div.quicktabs-views-group a').each(function() {
if (!$(this).hasClass('qtpersist')) {
var _href = $(this).attr('href');
$(this).attr('href', _href + '?qt-' + qt_name + '=' + i);
$(this).addClass('qtpersist');
}
})
});
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment