Skip to content
Browse files

[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...
1 parent 9ea70df commit c0a016eb6768e5df802715f8f50b3c9b47749ec9 @gabrielschulhof gabrielschulhof committed
Showing with 9 additions and 3 deletions.
  1. +9 −3 js/widgets/navbar.js
View
12 js/widgets/navbar.js
@@ -44,10 +44,16 @@ $.widget( "mobile.navbar", $.mobile.widget, {
}
});
- // Buttons in the navbar with ui-state-persist class should regain their active state before page show
- $navbar.closest( ".ui-page" ).bind( "pagebeforeshow", function() {
- $navbtns.filter( ".ui-state-persist" ).addClass( $.mobile.activeBtnClass );
+ $.extend( this, {
+ _navbtns: $navbtns
});
+
+ this._on( $navbar.closest( ".ui-page" ), { "pagebeforeshow": "_updateActiveClass" } );
+ },
+
+ _updateActiveClass: function() {
+ // Buttons in the navbar with ui-state-persist class should regain their active state before page show
+ this._navbtns.filter( ".ui-stat-persist" ).addClass( $.mobile.activeBtnClass );
}
});

0 comments on commit c0a016e

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