Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#5755 closed bug (fixed)

Tabs: tabs with an empty href are enabled in IE6/7

Reported by: chrismckee Owned by:
Priority: minor Milestone: 1.8.5
Component: ui.tabs Version: 1.8.2
Keywords: ie8, tabs, disabled Cc:
Blocked by: Blocking:

Description

As per this forum thread

http://forum.jquery.com/topic/jquery-ui-tabs-and-ie

(feel free to move this to jquery core if its more appropriate)


I had the same issue. I think I have a good idea why this is happening. It appears that the tabs plugin is using the jquery.inArray() method and expecting the return response to be -1 if the value is not found. This works as expected in other browsers, but IE is returning undefined. I think this is more an issue with the inArray method in jquery core. A simple patch to the method in the core would solve the problem, and is probably the way to go, but I felt more comfortable patching the tabs plugin. My solution is as follows: Somewhere around line # 7051 in the combined version of ui code is:

// disable tabs
  for (var i = 0, li; (li = this.lis[i]); i++) {
   $(li)[$.inArray(i, o.disabled) != -1 &&
    !$(li).hasClass('ui-tabs-selected') ? 'addClass' : 'removeClass']('ui-state-disabled');
  }

I added a check for the undefined value, replacing the above code with:

 for (var i = 0, li; (li = this.lis[i]); i++) {
   $(li)[$.inArray(i, o.disabled) != -1 && $.inArray(i, o.disabled) != undefined &&
    !$(li).hasClass('ui-tabs-selected') ? 'addClass' : 'removeClass']('ui-state-disabled');
  }

and everything worked in IE as expected. Hope this helps.

Change History (6)

comment:1 Changed 6 years ago by scottgonzalez

  • Priority changed from critical to minor

This has been repeatedly shown to work, but hasn't been shown to break. I've posted in the forum asking (again) for someone to create an example of the problem.

comment:2 Changed 6 years ago by srycroft

It's actually an IE <= 7 bug that enables tabs when it shouldn't with dynamically created HTML and an href of '#' Example: http://jsbin.com/uleta3/12

Go to IE 8 and switch between IE 7 and IE 8 browser mode to see the tabs enabled and disabled.

The problem code is in _tabify in the section that is trying to deal with an IE <= 7 href issue. It's setting the href variable to a.hash, which is blank. The code later thinks that this is a valid ajax tab, and enables it, instead of disabling it.

comment:3 Changed 6 years ago by scottgonzalez

  • Summary changed from IE8 Tabs Disabled by default to Tabs: tabs with an empty href are enabled in IE6/7

comment:4 Changed 6 years ago by scottgonzalez

  • Milestone changed from TBD to 1.9
  • Resolution set to fixed
  • Status changed from new to closed

Fixed in 1b31765.

Thanks for tracking down the real problem, srycroft.

comment:5 Changed 6 years ago by scottgonzalez

  • Milestone changed from 1.9 to 1.8.5

comment:6 Changed 6 years ago by Scott González

Tabs: Handle empty hrefs for IE6/7 as invalid. Fixes #5755 - Tabs: tabs with an empty href are enabled in IE6/7.

Changeset: 1b3176565561ccbd0c904620ae97690aff41b90b

Note: See TracTickets for help on using tickets.