Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
[navigation] vclick handler: Do not add active class if already added
Browse files Browse the repository at this point in the history
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
Gabriel Schulhof committed Nov 6, 2012
1 parent 6404d38 commit 35eea35
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions js/jquery.mobile.navigation.js
Expand Up @@ -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
Expand All @@ -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 );
}
}
Expand Down

0 comments on commit 35eea35

Please sign in to comment.