Skip to content
This repository
Browse code

[navbar] Move active state regain code out of _create() and into its …

…own prototype-level function and use ._on() to invoke it during "pagebeforeshow"
  • Loading branch information...
commit c0a016eb6768e5df802715f8f50b3c9b47749ec9 1 parent 9ea70df
Gabriel "_|Nix|_" Schulhof authored August 02, 2012

Showing 1 changed file with 9 additions and 3 deletions. Show diff stats Hide diff stats

  1. 12  js/widgets/navbar.js
12  js/widgets/navbar.js
@@ -44,10 +44,16 @@ $.widget( "mobile.navbar", $.mobile.widget, {
44 44
 			}
45 45
 		});
46 46
 
47  
-		// Buttons in the navbar with ui-state-persist class should regain their active state before page show
48  
-		$navbar.closest( ".ui-page" ).bind( "pagebeforeshow", function() {
49  
-			$navbtns.filter( ".ui-state-persist" ).addClass( $.mobile.activeBtnClass );
  47
+		$.extend( this, {
  48
+			_navbtns: $navbtns
50 49
 		});
  50
+
  51
+		this._on( $navbar.closest( ".ui-page" ), { "pagebeforeshow": "_updateActiveClass" } );
  52
+	},
  53
+
  54
+	_updateActiveClass: function() {
  55
+		// Buttons in the navbar with ui-state-persist class should regain their active state before page show
  56
+		this._navbtns.filter( ".ui-stat-persist" ).addClass( $.mobile.activeBtnClass );
51 57
 	}
52 58
 });
53 59
 

0 notes on commit c0a016e

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