Skip to main content

Bug Tracker

Side navigation

#1789 closed bug (fixed)

Opened October 10, 2007 09:18AM UTC

Closed October 21, 2007 03:09AM UTC

Last modified July 17, 2012 10:01AM UTC

Impossible to initialize an empty tabset

Reported by: klaus Owned by: klaus
Priority: minor Milestone: 1.2.2
Component: ui Version: 1.2.1
Keywords: tabs Cc:
Blocked by: Blocking:
Description

There is no possibility to initialize an empty tabset (e.g. to add all tabs dynamically.

Small fix in tabify() method (line 183) make things better:

if (this.$tabs.length && $.data(this.$tabs[o.initial], 'href')) {

Lines 362-373 of ui.tabs.js (add method):

 if (url.indexOf('#') == 0) { // ajax container is created by tabify automatically
  var $container = $(url);
  // try to find an existing element before creating a new one
  $container = ($container.length && $container || $('<div id="' + url.replace('#', '') + '" class="' + o.containerClass + ' ' + o.hideClass + '"></div>'))
    [method](position > 0 ? this.$containers[position - 1] : $(this.source));
}
var $foo = $('<li><a href="' + url + '"><span>' + text + '</span></a></li>'); 
if(position > 0) $foo[method](this.$tabs.slice(position - 1, position).parents('li:eq(0)'));
else {
  $foo.appendTo($(this.source));
  $container.removeClass('ui-tabs-hide');
}

Basically we've to check if this.$tabs array is not empty...

Attachments (0)
Change History (4)

Changed October 10, 2007 09:25AM UTC by klaus comment:1

description: There is no possibility to initialize an empty tabset (e.g. to add all tabs dynamically. Small fix in tabify() method (line 183) make things better: \ \ {{{ \ if (this.$tabs.length && $.data(this.$tabs[o.initial], 'href')) { \ }}} \ \ Basically we've to check if this.$tabs array is not empty...There is no possibility to initialize an empty tabset (e.g. to add all tabs dynamically. \ \ Small fix in tabify() method (line 183) make things better: \ \ {{{ \ if (this.$tabs.length && $.data(this.$tabs[o.initial], 'href')) { \ }}} \ \ Lines 362-373 of ui.tabs.js (add method): \ \ {{{ \ if (url.indexOf('#') == 0) { // ajax container is created by tabify automatically \ var $container = $(url); \ // try to find an existing element before creating a new one \ $container = ($container.length && $container || $('<div id="' + url.replace('#', '') + '" class="' + o.containerClass + ' ' + o.hideClass + '"></div>')) \ [method](position > 0 ? this.$containers[position - 1] : $(this.source)); \ } \ var $foo = $('<li><a href="' + url + '"><span>' + text + '</span></a></li>'); \ if(position > 0) $foo[method](this.$tabs.slice(position - 1, position).parents('li:eq(0)')); \ else { \ $foo.appendTo($(this.source)); \ $container.removeClass('ui-tabs-hide'); \ } \ }}} \ \ Basically we've to check if this.$tabs array is not empty...

Changed October 20, 2007 05:49PM UTC by klaus comment:2

status: newassigned

Changed October 21, 2007 03:09AM UTC by klaus comment:3

resolution: → fixed
status: assignedclosed

Changed July 17, 2012 10:01AM UTC by Nick Kusters <jquery@nickkusters.com> comment:4

Error Still Exists. See http://jsfiddle.net/zmRT8/18/ for Bug demo + workaround. Fix in the source should be as simple as checking if the UL element exists when calling .add, and adding it if it doesn't.