Skip to content

Commit 5444837

Browse files
committed
Add options for custom selectors.
This allows users to pass a selector for the tab content and any selector for tab links. It keeps the defaults.
1 parent 00851b7 commit 5444837

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

jquery.tabslet.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
animation: false,
4949
autorotate: false,
5050
deeplinking: false,
51+
tabSelector: '> ul li',
52+
contentSelector: '> div',
5153
pauseonhover: true,
5254
delay: 2000,
5355
active: 1,
@@ -64,13 +66,13 @@
6466

6567
var $this = $(this), _cache_li = [], _cache_div = [];
6668
var _container = options.container ? $(options.container) : $this;
67-
var _tabs = _container.find('> div');
69+
var _tabs = _container.find(options.contentSelector);
6870

6971
// Caching
7072
_tabs.each(function() { _cache_div.push($(this).css('display')); });
7173

7274
// Autorotate
73-
var elements = $this.find('> ul li'), i = options.active - 1; // ungly
75+
var elements = $this.find(options.tabSelector), i = options.active - 1; // ungly
7476

7577
if ( !$this.data( 'tabslet-init' ) ) {
7678

@@ -226,7 +228,7 @@
226228
$this.on ('destroy', function() {
227229
$(this)
228230
.removeData()
229-
.find('> ul li').each( function(i) {
231+
.find(options.tabSelector).each( function(i) {
230232
$(this).removeClass('active');
231233
});
232234
_tabs.each( function(i) {
@@ -242,4 +244,4 @@
242244

243245
$(document).ready(function () { $('[data-toggle="tabslet"]').tabslet(); });
244246

245-
})(jQuery);
247+
})(jQuery);

0 commit comments

Comments
 (0)