Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit c12d10f

Browse files
author
Gabriel Schulhof
committed
Collapsible set: Declare the same options as collapsible, and update child collapsibles when any of those options change.
1 parent f380d2a commit c12d10f

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

js/widgets/collapsibleSet.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@
55
//>>css.structure: ../css/structure/jquery.mobile.collapsible.css
66
//>>css.theme: ../css/themes/default/jquery.mobile.theme.css
77

8-
define( [ "jquery", "../jquery.mobile.widget", "./collapsible", "./addFirstLastClasses", "../jquery.mobile.registry" ], function( jQuery ) {
8+
define( [
9+
"jquery",
10+
"../jquery.mobile.widget",
11+
"./collapsible",
12+
"./addFirstLastClasses",
13+
"../jquery.mobile.registry" ], function( jQuery ) {
914
//>>excludeEnd("jqmBuildExclude");
1015
(function( $, undefined ) {
1116

17+
var childCollapsiblesSelector = ":mobile-collapsible, :jqmData(role='collapsible')";
18+
1219
$.widget( "mobile.collapsibleset", $.extend( {
20+
options: $.extend( {}, $.mobile.collapsible.defaults ),
21+
1322
_create: function() {
1423
var $el = this.element,
1524
o = this.options,
@@ -59,18 +68,24 @@ $.widget( "mobile.collapsibleset", $.extend( {
5968
},
6069

6170
_init: function() {
62-
var $el = this.element,
63-
collapsiblesInSet = $el.children( ":mobile-collapsible, :jqmData(role='collapsible')" ),
64-
expanded = collapsiblesInSet.filter( ":jqmData(collapsed='false')" );
6571
this._refresh( "true" );
6672

6773
// Because the corners are handled by the collapsible itself and the default state is collapsed
6874
// That was causing https://github.com/jquery/jquery-mobile/issues/4116
69-
expanded.trigger( "expand" );
75+
this.element
76+
.children( childCollapsiblesSelector )
77+
.filter( ":jqmData(collapsed='false')" )
78+
.trigger( "expand" );
79+
},
80+
81+
_setOptions: function( options ) {
82+
var ret = this._super( options );
83+
this.element.children( ":mobile-collapsible" ).collapsible( "refresh" );
84+
return ret;
7085
},
7186

7287
_refresh: function( create ) {
73-
var collapsiblesInSet = this.element.children( ":mobile-collapsible, :jqmData(role='collapsible')" );
88+
var collapsiblesInSet = this.element.children( childCollapsiblesSelector );
7489

7590
$.mobile.collapsible.prototype.enhance( collapsiblesInSet.not( ".ui-collapsible" ) );
7691

0 commit comments

Comments
 (0)