Skip to content

Instantly share code, notes, and snippets.

@jurchiks
Created November 1, 2013 12:17
Show Gist options
  • Save jurchiks/7264596 to your computer and use it in GitHub Desktop.
Save jurchiks/7264596 to your computer and use it in GitHub Desktop.
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