mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
UI Tabs: url containing a fragment identfier broke Ajax tab loading, fixes #3627
This commit is contained in:
parent
8f4ae539f3
commit
59c6f97625
@ -16,9 +16,7 @@
|
||||
<script type="text/javascript" src="tabs.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<div id="tabs1">
|
||||
<ul>
|
||||
<li><a href="#fragment-1">1</a></li>
|
||||
@ -33,12 +31,11 @@
|
||||
<ul>
|
||||
<li><a href="#colon:test">1</a></li>
|
||||
<li><a href="#inline-style">2</a></li>
|
||||
<li><a href="test.html#test">1</a></li>
|
||||
</ul>
|
||||
<div id="colon:test"></div>
|
||||
<div style="height: 300px;" id="inline-style"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -83,7 +83,8 @@ module('tabs');
|
||||
test('remove', function() {
|
||||
expect(4);
|
||||
|
||||
var el = $('#tabs1 > ul').tabs();
|
||||
var el = $('#tabs1').tabs();
|
||||
|
||||
el.tabs('remove', 0);
|
||||
equals(el.tabs('length'), 2, 'remove tab');
|
||||
equals($('li a[href$="fragment-1"]', el).length, 0, 'remove associated list item');
|
||||
@ -92,10 +93,9 @@ module('tabs');
|
||||
// TODO delete tab -> focus tab to right
|
||||
// TODO delete last tab -> focus tab to left
|
||||
|
||||
el = $('#tabs2 > ul').tabs({ selected: 1 });
|
||||
el.tabs('select', 1);
|
||||
el.tabs('remove', 1);
|
||||
equals(el.data('selected.tabs'), 0, 'update selected property');
|
||||
|
||||
});
|
||||
|
||||
test('enable', function() {
|
||||
@ -219,7 +219,7 @@ module('tabs: Tickets');
|
||||
};
|
||||
var expected = inlineStyle('height');
|
||||
|
||||
var el = $('#tabs2 > ul').tabs();
|
||||
var el = $('#tabs2').tabs();
|
||||
equals(inlineStyle('height'), expected, 'init should not remove inline style');
|
||||
|
||||
el.tabs('select', 1);
|
||||
@ -235,6 +235,15 @@ module('tabs: Tickets');
|
||||
|
||||
});
|
||||
|
||||
test('Ajax tab with url containing a fragment identifier fails to load, #3627', function() { // http://ui.jquery.com/bugs/ticket/3627
|
||||
expect(1);
|
||||
|
||||
var el = $('#tabs2').tabs();
|
||||
|
||||
equals( $('a:eq(2)', el).data('load.tabs'), 'test.html', 'should ignore fragment identifier' );
|
||||
|
||||
});
|
||||
|
||||
// test('', function() {
|
||||
// expect(0);
|
||||
//
|
||||
|
@ -96,14 +96,18 @@ $.widget("ui.tabs", {
|
||||
|
||||
var self = this, o = this.options;
|
||||
|
||||
var fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash
|
||||
this.$tabs.each(function(i, a) {
|
||||
var href = $(a).attr('href');
|
||||
|
||||
// inline tab
|
||||
if (a.hash && a.hash.replace('#', '')) // Safari 2 reports '#' for an empty hash
|
||||
self.$panels = self.$panels.add(self._sanitizeSelector(a.hash));
|
||||
if (fragmentId.test(href))
|
||||
self.$panels = self.$panels.add(self._sanitizeSelector(href));
|
||||
|
||||
// remote tab
|
||||
else if ($(a).attr('href') != '#') { // prevent loading the page itself if href is just "#"
|
||||
$.data(a, 'href.tabs', a.href); // required for restore on destroy
|
||||
$.data(a, 'load.tabs', a.href); // mutable
|
||||
else if (href != '#') { // prevent loading the page itself if href is just "#"
|
||||
$.data(a, 'href.tabs', href); // required for restore on destroy
|
||||
$.data(a, 'load.tabs', href.replace(/#.*$/, '')); // mutable data, NOTE IE fails to load if url contains fragment identifier - TODO jQuery Ajax bug?
|
||||
var id = self._tabId(a);
|
||||
a.href = '#' + id;
|
||||
var $panel = $('#' + id);
|
||||
@ -114,6 +118,7 @@ $.widget("ui.tabs", {
|
||||
}
|
||||
self.$panels = self.$panels.add($panel);
|
||||
}
|
||||
|
||||
// invalid tab href
|
||||
else
|
||||
o.disabled.push(i + 1);
|
||||
|
Loading…
Reference in New Issue
Block a user