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

Commit f52df7b

Browse files
author
Gabriel Schulhof
committed
Navigation: Try to get rid of call to .closest( ".ui-btn" ) by making use of buttonElements data added during buttonMarkup()
1 parent b5ccb80 commit f52df7b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

js/jquery.mobile.navigation.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ define( [
13301330

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

1360-
$btn = $target.closest( ".ui-btn" ).not( ".ui-disabled" );
1362+
btnEls = $.data( $target[ 0 ], "buttonElements" );
1363+
if ( btnEls ) {
1364+
$target = $( btnEls.outer );
1365+
} else {
1366+
$target = $target.closest( ".ui-btn" );
1367+
}
1368+
1369+
$btn = $target.not( ".ui-disabled" );
13611370
if ( !$btn.hasClass( $.mobile.activeBtnClass ) ) {
13621371
removeActiveLinkClass( true );
13631372
$activeClickedLink = $btn;

0 commit comments

Comments
 (0)