From 60f20e06e2ec6d64dec77947bfe50c2c8fb2690d Mon Sep 17 00:00:00 2001 From: Ghislain Seguin Date: Wed, 22 Feb 2012 17:41:52 -0800 Subject: [PATCH] Fixes #3529 - Added refresh method to collapsibleset widget --- js/jquery.mobile.collapsibleSet.js | 58 +++++++++++++++++------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/js/jquery.mobile.collapsibleSet.js b/js/jquery.mobile.collapsibleSet.js index 583250b18a5..79ee33d5eda 100644 --- a/js/jquery.mobile.collapsibleSet.js +++ b/js/jquery.mobile.collapsibleSet.js @@ -12,8 +12,7 @@ $.widget( "mobile.collapsibleset", $.mobile.widget, { }, _create: function() { var $el = this.element.addClass( "ui-collapsible-set" ), - o = this.options, - collapsiblesInSet = $el.children( ":jqmData(role='collapsible')" ); + o = this.options; // Inherit the theme from collapsible-set if ( !o.theme ) { @@ -26,7 +25,6 @@ $.widget( "mobile.collapsibleset", $.mobile.widget, { // Initialize the collapsible set if it's not already initialized if ( !$el.jqmData( "collapsiblebound" ) ) { - $el .jqmData( "collapsiblebound", true ) .bind( "expand collapse", function( event ) { @@ -47,32 +45,42 @@ $.widget( "mobile.collapsibleset", $.mobile.widget, { .closest( ".ui-collapsible" ) .siblings( ".ui-collapsible" ) .trigger( "collapse" ); - }); + } + }, - // clean up borders - collapsiblesInSet.each( function() { - $( this ).find( $.mobile.collapsible.prototype.options.heading ) - .find( "a" ).first() - .add( ".ui-btn-inner" ) - .removeClass( "ui-corner-top ui-corner-bottom" ); - }); + _init: function() { + this.refresh(); + }, - collapsiblesInSet.first() - .find( "a" ) - .first() - .addClass( "ui-corner-top" ) - .find( ".ui-btn-inner" ) - .addClass( "ui-corner-top" ); + refresh: function() { + var $el = this.element, + collapsiblesInSet = $el.children( ":jqmData(role='collapsible')" ); - collapsiblesInSet.last() - .jqmData( "collapsible-last", true ) - .find( "a" ) - .first() - .addClass( "ui-corner-bottom" ) - .find( ".ui-btn-inner" ) - .addClass( "ui-corner-bottom" ); - } + $.mobile.collapsible.prototype.enhance( collapsiblesInSet ); + + // clean up borders + collapsiblesInSet.each( function() { + $( this ).find( $.mobile.collapsible.prototype.options.heading ) + .find( "a" ).first() + .add( ".ui-btn-inner" ) + .removeClass( "ui-corner-top ui-corner-bottom" ); + }); + + collapsiblesInSet.first() + .find( "a" ) + .first() + .addClass( "ui-corner-top" ) + .find( ".ui-btn-inner" ) + .addClass( "ui-corner-top" ); + + collapsiblesInSet.last() + .jqmData( "collapsible-last", true ) + .find( "a" ) + .first() + .addClass( "ui-corner-bottom" ) + .find( ".ui-btn-inner" ) + .addClass( "ui-corner-bottom" ); } });