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

Commit

Permalink
Navigation: Try to get rid of call to .closest( ".ui-btn" ) by making…
Browse files Browse the repository at this point in the history
… use of buttonElements data added during buttonMarkup()
  • Loading branch information
Gabriel Schulhof committed Nov 27, 2012
1 parent b5ccb80 commit f52df7b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions js/jquery.mobile.navigation.js
Expand Up @@ -1330,7 +1330,7 @@ define( [

//add active state on vclick
$( document ).bind( "vclick", function( event ) {
var link, $link, $btn, $target = $( event.target );
var link, $link, $btn, btnEls, $target = $( event.target );
// if this isn't a left click we don't care. Its important to note
// that when the virtual event is generated it will create the which attr
if ( event.which > 1 || !$.mobile.linkBindingEnabled ) {
Expand All @@ -1340,6 +1340,8 @@ define( [
if ( $target.data( "mobile-button" ) ) {
if ( !getAjaxFormData( $target.closest( "form" ), true ) ) {
return;
} else {
$target = $target.parent();
}
} else {
link = findClosestLink( event.target );
Expand All @@ -1357,7 +1359,14 @@ define( [
$target = $link;
}

$btn = $target.closest( ".ui-btn" ).not( ".ui-disabled" );
btnEls = $.data( $target[ 0 ], "buttonElements" );
if ( btnEls ) {
$target = $( btnEls.outer );
} else {
$target = $target.closest( ".ui-btn" );
}

$btn = $target.not( ".ui-disabled" );
if ( !$btn.hasClass( $.mobile.activeBtnClass ) ) {
removeActiveLinkClass( true );
$activeClickedLink = $btn;
Expand Down

0 comments on commit f52df7b

Please sign in to comment.