mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-09 00:50:58 +00:00
made sure linking to the same page from within a dialog closes the dialog.
This commit is contained in:
parent
be8eb3d0c6
commit
2ebf659fbd
1 changed files with 11 additions and 4 deletions
|
|
@ -13,17 +13,24 @@ $.widget( "mobile.dialog", $.mobile.widget, {
|
|||
$closeBtn = $('<a href="#" data-icon="delete" data-iconpos="notext">Close</a>'),
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue