mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-13 10:51:02 +00:00
fixed support for back button closing of dialogs, utilizing new $.mobile.updateHash method. Fixes #412
This commit is contained in:
parent
f03e59b0b3
commit
812e4c6978
1 changed files with 13 additions and 2 deletions
|
|
@ -10,8 +10,9 @@ $.widget( "mobile.dialog", $.mobile.widget, {
|
|||
_create: function(){
|
||||
var self = this,
|
||||
$el = self.element,
|
||||
$prevPage = $.activePage,
|
||||
$closeBtn = $('<a href="#" data-icon="delete" data-iconpos="notext">Close</a>');
|
||||
|
||||
|
||||
$el.delegate("a, submit", "click submit", function(e){
|
||||
if( e.type == "click" && ( $(e.target).closest('[data-back]') || $(e.target).closest($closeBtn) ) ){
|
||||
self.close();
|
||||
|
|
@ -38,10 +39,20 @@ $.widget( "mobile.dialog", $.mobile.widget, {
|
|||
.find('.ui-content,[data-role=footer]')
|
||||
.last()
|
||||
.addClass('ui-corner-bottom ui-overlay-shadow');
|
||||
|
||||
$(window).bind('hashchange',function(){
|
||||
if( $el.is('.ui-page-active') ){
|
||||
self.close();
|
||||
$el.bind('pagehide',function(){
|
||||
$.mobile.updateHash( $prevPage.attr('id'), true);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
close: function(){
|
||||
$.changePage([this.element, $.activePage], undefined, true );
|
||||
$.changePage([this.element, $.activePage], undefined, true, true );
|
||||
}
|
||||
});
|
||||
})( jQuery );
|
||||
Loading…
Reference in a new issue