mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Accordion: Pass header and content in create event. Fixes #7869 - Accordion: Provide header and content details in create event.
This commit is contained in:
parent
ecddf469d7
commit
3919256abd
@ -2,6 +2,45 @@
|
||||
|
||||
module( "accordion: events", accordion_setupTeardown() );
|
||||
|
||||
test( "create", function() {
|
||||
expect( 10 );
|
||||
|
||||
var element = $( "#list1" ),
|
||||
headers = element.children( "h3" ),
|
||||
contents = headers.next();
|
||||
|
||||
element.accordion({
|
||||
create: function( event, ui ) {
|
||||
equals( ui.header.size(), 1, "header size" );
|
||||
strictEqual( ui.header[ 0 ], headers[ 0 ], "header" );
|
||||
equals( ui.content.size(), 1, "content size" );
|
||||
strictEqual( ui.content[ 0 ], contents[ 0 ], "content" );
|
||||
}
|
||||
});
|
||||
element.accordion( "destroy" );
|
||||
|
||||
element.accordion({
|
||||
active: 2,
|
||||
create: function( event, ui ) {
|
||||
equals( ui.header.size(), 1, "header size" );
|
||||
strictEqual( ui.header[ 0 ], headers[ 2 ], "header" );
|
||||
equals( ui.content.size(), 1, "content size" );
|
||||
strictEqual( ui.content[ 0 ], contents[ 2 ], "content" );
|
||||
}
|
||||
});
|
||||
element.accordion( "destroy" );
|
||||
|
||||
element.accordion({
|
||||
active: false,
|
||||
collapsible: true,
|
||||
create: function( event, ui ) {
|
||||
equals( ui.header.size(), 0, "header size" );
|
||||
equals( ui.content.size(), 0, "content size" );
|
||||
}
|
||||
});
|
||||
element.accordion( "destroy" );
|
||||
});
|
||||
|
||||
test( "beforeActivate", function() {
|
||||
expect( 38 );
|
||||
var element = $( "#list1" ).accordion({
|
||||
|
7
ui/jquery.ui.accordion.js
vendored
7
ui/jquery.ui.accordion.js
vendored
@ -103,6 +103,13 @@ $.widget( "ui.accordion", {
|
||||
this._setupEvents( options.event );
|
||||
},
|
||||
|
||||
_getCreateEventData: function() {
|
||||
return {
|
||||
header: this.active,
|
||||
content: !this.active.length ? $() : this.active.next()
|
||||
};
|
||||
},
|
||||
|
||||
_createIcons: function() {
|
||||
var icons = this.options.icons;
|
||||
if ( icons ) {
|
||||
|
Loading…
Reference in New Issue
Block a user