Skip to content

Commit bc7af40

Browse files
Patrick McElhaneypmcelhaney
Patrick McElhaney
authored andcommitted
Tabs: Extended URL method to get as well as set URL.
1 parent ed57047 commit bc7af40

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

tests/unit/tabs/tabs_methods.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,15 @@ test('load', function() {
166166
});
167167

168168
test('url', function() {
169-
ok(false, "missing test - untested code is broken code.");
169+
el = $('#tabs1').tabs();
170+
el.tabs('url', 1, '#newurl');
171+
equals($('#tabs1 > ul > li:eq(1) a').data('load.tabs'), '#newurl', 'should change tab URL')
172+
equals(el.tabs('url', 1), '#newurl', 'should get the URL for tab 1')
173+
174+
el.tabs('url', 2, '#selectedurl');
175+
el.tabs('select', 2);
176+
equals(el.tabs('url'), '#selectedurl', 'should get the URL for selected tab')
177+
170178
});
171179

172180
test('length', function() {

ui/jquery.ui.tabs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,12 @@ $.widget( "ui.tabs", {
661661
},
662662

663663
url: function( index, url ) {
664+
// getter
665+
if (arguments.length < 2) {
666+
return this.anchors.eq( arguments.length ? index : this.options.selected ).data( "load.tabs" );
667+
}
668+
669+
// setter
664670
this.anchors.eq( index ).removeData( "cache.tabs" ).data( "load.tabs", url );
665671
return this;
666672
},

0 commit comments

Comments
 (0)