From 2ebf659fbd5c705fe032796fbc3880c800463f5d Mon Sep 17 00:00:00 2001 From: scottjehl Date: Sun, 23 Jan 2011 18:26:48 -0500 Subject: [PATCH] made sure linking to the same page from within a dialog closes the dialog. --- js/jquery.mobile.dialog.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/js/jquery.mobile.dialog.js b/js/jquery.mobile.dialog.js index b1747957..599c4013 100644 --- a/js/jquery.mobile.dialog.js +++ b/js/jquery.mobile.dialog.js @@ -13,17 +13,24 @@ $.widget( "mobile.dialog", $.mobile.widget, { $closeBtn = $('Close'), dialogClickHandler = function(e){ - var $target = $(e.target); + var $target = $(e.target), + href = $.mobile.path.stripHash( $target.closest("a").attr("href") ), + isRelative = $.mobile.path.isRelative( href ), + absUrl = isRelative ? $.mobile.path.makeAbsolute( href ) : href; // fixes issues with target links in dialogs breaking // page transitions by reseting the active page below - if( $.mobile.path.isExternal( $target.closest("a").attr("href") ) || + if( $.mobile.path.isExternal( href ) || $target.closest("a[target]").length || $target.is( "[rel='external']" ) ) { return; } - - if( e.type == "click" && this==$closeBtn[0] ){ + + + //if it's a close button click + //or the href is the same as the page we're on, close the dialog + if( e.type == "click" && + ( this==$closeBtn[0] || absUrl == $.mobile.path.stripHash( location.hash ) ) ){ self.close(); return false; }