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

Commit 4d22d47

Browse files
author
Gabriel Schulhof
committed
[collapsibleset] Maintain ui-first-child and ui-last-child during refresh()
1 parent 263e908 commit 4d22d47

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

js/widgets/collapsibleSet.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,31 @@ $.widget( "mobile.collapsibleset", $.mobile.widget, {
5656
var $el = this.element,
5757
collapsiblesInSet = $el.children( ":jqmData(role='collapsible')" ),
5858
expanded = collapsiblesInSet.filter( ":jqmData(collapsed='false')" );
59-
this.refresh();
59+
this._refresh( "true" );
6060

6161
// Because the corners are handled by the collapsible itself and the default state is collapsed
6262
// That was causing https://github.com/jquery/jquery-mobile/issues/4116
6363
expanded.trigger( "expand" );
6464
},
6565

66-
refresh: function() {
66+
_refresh: function( create ) {
6767
var $el = this.element,
6868
o = this.options,
6969
collapsiblesInSet = $el.children( ":jqmData(role='collapsible')" );
7070

7171
$.mobile.collapsible.prototype.enhance( collapsiblesInSet.not( ".ui-collapsible" ) );
72+
collapsiblesInSet.removeClass( "ui-first-child ui-last-child" );
73+
if ( !create ) {
74+
collapsiblesInSet = collapsiblesInSet.filter( ":visible" );
75+
}
76+
collapsiblesInSet
77+
.eq( 0 ).addClass( "ui-first-child" )
78+
.end()
79+
.last().addClass( "ui-last-child" );
80+
},
81+
82+
refresh: function() {
83+
this._refresh( false );
7284
}
7385
});
7486

0 commit comments

Comments
 (0)