Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Option to set close url to dialog widget #5117

Closed
wants to merge 1 commit into from

2 participants

@ermajn

In my example, history.back() was overwriting results that I made with dialog, so I needed option to set close url for dialog widget.
Here is my proposal for this.

@toddparker

Thanks so much for the PR but we're just about to land a new feature to allow people to specify the position of the close button in dialogs or specify "none". If you specify none, you can then write you own custom button that could specify a different close URL by setting the href in the markup. We think this is the more flexible way to go.

See: #3886

@toddparker toddparker closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 2, 2012
  1. @ermajn
This page is out of date. Refresh to see the latest.
Showing with 17 additions and 10 deletions.
  1. +17 −10 js/widgets/dialog.js
View
27 js/widgets/dialog.js
@@ -13,7 +13,8 @@ $.widget( "mobile.dialog", $.mobile.widget, {
options: {
closeBtnText: "Close",
overlayTheme: "a",
- initSelector: ":jqmData(role='dialog')"
+ initSelector: ":jqmData(role='dialog')",
+ closeUrl: undefined
},
_create: function() {
var self = this,
@@ -81,21 +82,27 @@ $.widget( "mobile.dialog", $.mobile.widget, {
});
},
- // Close method goes back in history
+ // Close method goes back in history unless closeUrl option is set
close: function() {
var dst;
if ( this._isCloseable ) {
this._isCloseable = false;
- if ( $.mobile.hashListeningEnabled ) {
- $.mobile.back();
- } else {
- dst = $.mobile.urlHistory.getPrev().url;
- if ( !$.mobile.path.isPath( dst ) ) {
- dst = $.mobile.path.makeUrlAbsolute( "#" + dst );
+
+ if (this.options.closeUrl !== undefined) {
+ $.mobile.changePage( this.options.closeUrl );
+ } else {
+
+ if ( $.mobile.hashListeningEnabled ) {
+ $.mobile.back();
+ } else {
+ dst = $.mobile.urlHistory.getPrev().url;
+ if ( !$.mobile.path.isPath( dst ) ) {
+ dst = $.mobile.path.makeUrlAbsolute( "#" + dst );
+ }
+
+ $.mobile.changePage( dst, { changeHash: false, fromHashChange: true } );
}
-
- $.mobile.changePage( dst, { changeHash: false, fromHashChange: true } );
}
}
}
Something went wrong with that request. Please try again.