Skip to content

Commit 812e4c6

Browse files
author
scottjehl
committed
fixed support for back button closing of dialogs, utilizing new $.mobile.updateHash method. Fixes jquery-archive#412
1 parent f03e59b commit 812e4c6

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

js/jquery.mobile.dialog.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ $.widget( "mobile.dialog", $.mobile.widget, {
1010
_create: function(){
1111
var self = this,
1212
$el = self.element,
13+
$prevPage = $.activePage,
1314
$closeBtn = $('<a href="#" data-icon="delete" data-iconpos="notext">Close</a>');
14-
15+
1516
$el.delegate("a, submit", "click submit", function(e){
1617
if( e.type == "click" && ( $(e.target).closest('[data-back]') || $(e.target).closest($closeBtn) ) ){
1718
self.close();
@@ -38,10 +39,20 @@ $.widget( "mobile.dialog", $.mobile.widget, {
3839
.find('.ui-content,[data-role=footer]')
3940
.last()
4041
.addClass('ui-corner-bottom ui-overlay-shadow');
42+
43+
$(window).bind('hashchange',function(){
44+
if( $el.is('.ui-page-active') ){
45+
self.close();
46+
$el.bind('pagehide',function(){
47+
$.mobile.updateHash( $prevPage.attr('id'), true);
48+
});
49+
}
50+
});
4151

4252
},
53+
4354
close: function(){
44-
$.changePage([this.element, $.activePage], undefined, true );
55+
$.changePage([this.element, $.activePage], undefined, true, true );
4556
}
4657
});
4758
})( jQuery );

0 commit comments

Comments
 (0)