Skip to content

Commit

Permalink
Tabs: Fixed IE bug which would mistake tabs as ajax with dynamically …
Browse files Browse the repository at this point in the history
…created HTML, fixes #4033
  • Loading branch information
Klaus Hartl committed Feb 1, 2009
1 parent 1866e13 commit c8360e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/unit/tabs/tabs.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -262,6 +262,17 @@ module('tabs: Tickets');
equals( $('a:eq(2)', el).data('load.tabs'), 'test.html', 'should ignore fragment identifier' ); equals( $('a:eq(2)', el).data('load.tabs'), 'test.html', 'should ignore fragment identifier' );


}); });

test('IE expands hash to full url and misinterprets tab as ajax, #4033', function() { // http://ui.jquery.com/bugs/ticket/4033
expect(1);

el = $('<div><ul><li><a href="#tab">Tab</a></li></ul><div id="tab"></div></div>')
.appendTo('#main').tabs();

equals($('a', el).data('load.tabs'), undefined, 'should not create ajax tab');

});



// test('', function() { // test('', function() {
// expect(0); // expect(0);
Expand Down
4 changes: 4 additions & 0 deletions ui/ui.tabs.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ $.widget("ui.tabs", {
var fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash var fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash
this.$tabs.each(function(i, a) { this.$tabs.each(function(i, a) {
var href = $(a).attr('href'); var href = $(a).attr('href');

// For dynamically created HTML that contains a hash as href IE expands
// such href to the full page url with hash and then misinterprets tab as ajax...
if (href.split('#')[0] == location.toString().split('#')[0]) href = a.hash;


// inline tab // inline tab
if (fragmentId.test(href)) if (fragmentId.test(href))
Expand Down

0 comments on commit c8360e6

Please sign in to comment.