简体   繁体   中英

Not to close on esc or by clicking outside of the dialog box

Currently, for my own project, I am using the following library or plugin (which one you called it) for pop up, it is way a great plugin, I really like that, but one thing that I want to modify is to not to close the dialog box on pressing the esc key or by clicking outside of the dialog box.

I already look at the JQuery UI.js file and there is a variable called closeOnEscape and a bunch of function logic to handle closeOnEscape on the dialog.

Is there any way that I can implement to modify like closeOnEscape to this great library or plugin? as well as not to close by clicking outside of the dialog box.

Here is the link:

Dialog

JS File

First of all, sorry to not post any codes or whatsoever.

Your answer much appreciated.

Thanks.

Try this one:

  $(document).on('keydown', function(ev) {
  if (ev.keyCode === 27) {
      ev.preventDefault();
  }
  });



$(document).on('click', function(ev) {
      if ($(this).hasClass('you outside box class')) {
          ev.preventDefault();
      }
  });

Hope this helps

There is a property called escape : true,

I assume you could set this to false

or in the actual plug in look for and change its function

if (key_code === 27) {
        $[prefix]('close');
}

and change it to

//   if (key_code === 27) {
//        $[prefix]('close');
//   }

That should disable the Escape Key

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM