Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
jQuery UI modal dialog close on overlay click option.
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index c5bd42a..9512c10 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -26,6 +26,7 @@ $.widget( "ui.dialog", {
autoOpen: true,
buttons: [],
closeOnEscape: true,
+ closeOnOverlayClick: false,
closeText: "Close",
dialogClass: "",
draggable: true,
@@ -778,9 +779,15 @@ $.widget( "ui.dialog", {
this.overlay = $("<div>")
.addClass("ui-widget-overlay ui-front")
.appendTo( this._appendTo() );
- this._on( this.overlay, {
+ var events = {
mousedown: "_keepFocus"
- });
+ };
+
+ if ( this.options.closeOnOverlayClick ) {
+ events.click = "close";
+ }
+
+ this._on( this.overlay, events );
this.document.data( "ui-dialog-overlays",
(this.document.data( "ui-dialog-overlays" ) || 0) + 1 );
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.