Skip to content
This repository
Browse code

Fixes #3529 - Added refresh method to collapsibleset widget

  • Loading branch information...
commit 60f20e06e2ec6d64dec77947bfe50c2c8fb2690d 1 parent b4e0389
Ghislain Seguin authored February 22, 2012

Showing 1 changed file with 33 additions and 25 deletions. Show diff stats Hide diff stats

  1. 58  js/jquery.mobile.collapsibleSet.js
58  js/jquery.mobile.collapsibleSet.js
@@ -12,8 +12,7 @@ $.widget( "mobile.collapsibleset", $.mobile.widget, {
12 12
 	},
13 13
 	_create: function() {
14 14
 		var $el = this.element.addClass( "ui-collapsible-set" ),
15  
-			o = this.options,
16  
-			collapsiblesInSet = $el.children( ":jqmData(role='collapsible')" );
  15
+			o = this.options;
17 16
 
18 17
 		// Inherit the theme from collapsible-set
19 18
 		if ( !o.theme ) {
@@ -26,7 +25,6 @@ $.widget( "mobile.collapsibleset", $.mobile.widget, {
26 25
 
27 26
 		// Initialize the collapsible set if it's not already initialized
28 27
 		if ( !$el.jqmData( "collapsiblebound" ) ) {
29  
-
30 28
 			$el
31 29
 				.jqmData( "collapsiblebound", true )
32 30
 				.bind( "expand collapse", function( event ) {
@@ -47,32 +45,42 @@ $.widget( "mobile.collapsibleset", $.mobile.widget, {
47 45
 						.closest( ".ui-collapsible" )
48 46
 						.siblings( ".ui-collapsible" )
49 47
 						.trigger( "collapse" );
50  
-
51 48
 				});
  49
+		}
  50
+	},
52 51
 
53  
-			// clean up borders
54  
-			collapsiblesInSet.each( function() {
55  
-				$( this ).find( $.mobile.collapsible.prototype.options.heading )
56  
-					.find( "a" ).first()
57  
-					.add( ".ui-btn-inner" )
58  
-					.removeClass( "ui-corner-top ui-corner-bottom" );
59  
-			});
  52
+	_init: function() {
  53
+		this.refresh();
  54
+	},
60 55
 
61  
-			collapsiblesInSet.first()
62  
-				.find( "a" )
63  
-					.first()
64  
-					.addClass( "ui-corner-top" )
65  
-						.find( ".ui-btn-inner" )
66  
-							.addClass( "ui-corner-top" );
  56
+	refresh: function() {
  57
+		var $el = this.element,
  58
+			collapsiblesInSet = $el.children( ":jqmData(role='collapsible')" );
67 59
 
68  
-			collapsiblesInSet.last()
69  
-				.jqmData( "collapsible-last", true )
70  
-				.find( "a" )
71  
-					.first()
72  
-					.addClass( "ui-corner-bottom" )
73  
-						.find( ".ui-btn-inner" )
74  
-							.addClass( "ui-corner-bottom" );
75  
-		}
  60
+		$.mobile.collapsible.prototype.enhance( collapsiblesInSet );
  61
+
  62
+		// clean up borders
  63
+		collapsiblesInSet.each( function() {
  64
+			$( this ).find( $.mobile.collapsible.prototype.options.heading )
  65
+				.find( "a" ).first()
  66
+				.add( ".ui-btn-inner" )
  67
+				.removeClass( "ui-corner-top ui-corner-bottom" );
  68
+		});
  69
+
  70
+		collapsiblesInSet.first()
  71
+			.find( "a" )
  72
+				.first()
  73
+				.addClass( "ui-corner-top" )
  74
+				.find( ".ui-btn-inner" )
  75
+					.addClass( "ui-corner-top" );
  76
+
  77
+		collapsiblesInSet.last()
  78
+			.jqmData( "collapsible-last", true )
  79
+			.find( "a" )
  80
+				.first()
  81
+				.addClass( "ui-corner-bottom" )
  82
+				.find( ".ui-btn-inner" )
  83
+					.addClass( "ui-corner-bottom" );
76 84
 	}
77 85
 });
78 86
 

0 notes on commit 60f20e0

Please sign in to comment.
Something went wrong with that request. Please try again.