Permalink
Browse files

[navigation] vclick handler: Do not add active class if already added

This helps avoid setting an element which has the active class added by hand as $activeClickedLink, which will cause that element to lose its active class if another link is activated.
  • Loading branch information...
gabrielschulhof committed Nov 6, 2012
1 parent 6404d38 commit 35eea35a42aba78146786d67fef6f5fc7985d701
Showing with 4 additions and 3 deletions.
  1. +4 −3 js/jquery.mobile.navigation.js
@@ -1325,7 +1325,7 @@ define( [
return;
}
var link = findClosestLink( event.target );
var link = findClosestLink( event.target ), $btn;
// split from the previous return logic to avoid find closest where possible
// TODO teach $.mobile.hijackable to operate on raw dom elements so the link wrapping
@@ -1335,9 +1335,10 @@ define( [
}
if ( link ) {
if ( path.parseUrl( link.getAttribute( "href" ) || "#" ).hash !== "#" ) {
$btn = $( link ).closest( ".ui-btn" ).not( ".ui-disabled" );
if ( path.parseUrl( link.getAttribute( "href" ) || "#" ).hash !== "#" && !$btn.hasClass( $.mobile.activeBtnClass ) ) {
removeActiveLinkClass( true );
$activeClickedLink = $( link ).closest( ".ui-btn" ).not( ".ui-disabled" );
$activeClickedLink = $btn;
$activeClickedLink.addClass( $.mobile.activeBtnClass );
}
}

0 comments on commit 35eea35

Please sign in to comment.