mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Tabs: Pass tab and panel in create event. Fixes #7868 - Tabs: Provide tab and panel details in create event.
This commit is contained in:
parent
da89fcbc07
commit
6800e1a2f9
@ -2,6 +2,45 @@
|
|||||||
|
|
||||||
module( "tabs: events" );
|
module( "tabs: events" );
|
||||||
|
|
||||||
|
test( "create", function() {
|
||||||
|
expect( 10 );
|
||||||
|
|
||||||
|
var element = $( "#tabs1" ),
|
||||||
|
tabs = element.find( "ul a" ),
|
||||||
|
panels = element.children( "div" );
|
||||||
|
|
||||||
|
element.tabs({
|
||||||
|
create: function( event, ui ) {
|
||||||
|
equals( ui.tab.size(), 1, "tab size" );
|
||||||
|
strictEqual( ui.tab[ 0 ], tabs[ 0 ], "tab" );
|
||||||
|
equals( ui.panel.size(), 1, "panel size" );
|
||||||
|
strictEqual( ui.panel[ 0 ], panels[ 0 ], "panel" );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
element.tabs( "destroy" );
|
||||||
|
|
||||||
|
element.tabs({
|
||||||
|
active: 2,
|
||||||
|
create: function( event, ui ) {
|
||||||
|
equals( ui.tab.size(), 1, "tab size" );
|
||||||
|
strictEqual( ui.tab[ 0 ], tabs[ 2 ], "tab" );
|
||||||
|
equals( ui.panel.size(), 1, "panel size" );
|
||||||
|
strictEqual( ui.panel[ 0 ], panels[ 2 ], "panel" );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
element.tabs( "destroy" );
|
||||||
|
|
||||||
|
element.tabs({
|
||||||
|
active: false,
|
||||||
|
collapsible: true,
|
||||||
|
create: function( event, ui ) {
|
||||||
|
equals( ui.tab.size(), 0, "tab size" );
|
||||||
|
equals( ui.panel.size(), 0, "panel size" );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
element.tabs( "destroy" );
|
||||||
|
});
|
||||||
|
|
||||||
test( "beforeActivate", function() {
|
test( "beforeActivate", function() {
|
||||||
expect( 38 );
|
expect( 38 );
|
||||||
|
|
||||||
|
7
ui/jquery.ui.tabs.js
vendored
7
ui/jquery.ui.tabs.js
vendored
@ -120,6 +120,13 @@ $.widget( "ui.tabs", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getCreateEventData: function() {
|
||||||
|
return {
|
||||||
|
tab: this.active,
|
||||||
|
panel: !this.active.length ? $() : this._getPanelForTab( this.active )
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
_setOption: function( key, value ) {
|
_setOption: function( key, value ) {
|
||||||
if ( key == "active" ) {
|
if ( key == "active" ) {
|
||||||
// _activate() will handle invalid values and update this.options
|
// _activate() will handle invalid values and update this.options
|
||||||
|
Loading…
Reference in New Issue
Block a user