# Make dismissing a modal pop-up by clicking outside window optional

**URL:** <https://forums.knack.com/t/make-dismissing-a-modal-pop-up-by-clicking-outside-window-optional/9646>\
**Category:** Feature Requests\
**Tags:** uiux-live-app, usability, workaround-available\
**Created:** [July 7, 2015, 3:51pm UTC](https://forums.knack.com/t/make-dismissing-a-modal-pop-up-by-clicking-outside-window-optional/9646 "2015-07-07T15:51:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricAlderm88922](https://avatars.discourse-cdn.com/v4/letter/e/eada6e/32.png) [@EricAlderm88922](https://forums.knack.com/u/EricAlderm88922)\
**Post date:** [July 7, 2015, 3:51pm UTC](https://forums.knack.com/t/make-dismissing-a-modal-pop-up-by-clicking-outside-window-optional/9646/1 "2015-07-07T15:51:00Z")

</div>

As a Knack user, I want to know that there is consistency in my mouse actions. Some examples:

- mouseup (release not click) outside a Rich Text editor in Chrome closes window and does not save edits; see attached gif
- clicking outside a modal window to close a record view or a table view can be helpful, but not when you're editing and lose your work
- could this be app / page / view set?

---

<div class="post-metadata">

**Author:** ![BradStevens](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/bradstevens/32/140_2.png) [@BradStevens](https://forums.knack.com/u/BradStevens)\
**Post date:** [September 20, 2019, 4:18am UTC](https://forums.knack.com/t/make-dismissing-a-modal-pop-up-by-clicking-outside-window-optional/9646/2 "2019-09-20T04:18:36Z")

</div>

Thanks for sharing Matt - we've needed to implement this for a while and just got around to it.

Still works perfectly.

---

<div class="post-metadata">

**Author:** ![MattThomso16358](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@MattThomso16358](https://forums.knack.com/u/MattThomso16358)\
**Post date:** [March 28, 2019, 10:20pm UTC](https://forums.knack.com/t/make-dismissing-a-modal-pop-up-by-clicking-outside-window-optional/9646/3 "2019-03-28T22:20:49Z")

</div>

This was also an issue for us especially with longer forms.

I asked support and Odalis replied back with the following Javascript snippet - which appears to be working perfectly.&nbsp;

Give it a try;

&nbsp;

```
$(document).on('knack-scene-render.any', function(event, scene) {
    $('.kn-modal-bg').off('click');
});
```

---

<div class="post-metadata">

**Author:** ![TreyPeirce56514](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@TreyPeirce56514](https://forums.knack.com/u/TreyPeirce56514)\
**Post date:** [February 11, 2019, 9:56pm UTC](https://forums.knack.com/t/make-dismissing-a-modal-pop-up-by-clicking-outside-window-optional/9646/4 "2019-02-11T21:56:56Z")

</div>

Has anyone found a solution to this? This seems like it would be relatively simple for Knack to implement. It is incredibly frustrating because if you quickly select text and your pointer slightly goes off screen it will close the modal pop-up and lose all the data in the form.

&nbsp;

We tried adding this JS:&nbsp;

$(document).on('knack-scene-render.any', function(event,page) {  
  
$('#kn-modal-bg-0').modal-content({backdrop: 'static', keyboard: false})   
  
});

but it didn't have the intended result.

---

<div class="post-metadata">

**Author:** ![JoshHeald32800](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/joshheald32800/32/614_2.png) [@JoshHeald32800](https://forums.knack.com/u/JoshHeald32800)\
**Post date:** [September 19, 2018, 8:58am UTC](https://forums.knack.com/t/make-dismissing-a-modal-pop-up-by-clicking-outside-window-optional/9646/5 "2018-09-19T08:58:16Z")

</div>

This seems to affect a number of our users on some date entry intensive forms. We have a form which gives users the option to add a linked connected record as a new option, rather than selecting an existing record from the drop down. This seemingly can only be displayed in a modal, and one errant click will lose a lot of work for people using the forms.

&nbsp;

It's depressing to have to advise users to type everything in a word processor and copy it across, but that's really all I can do here.

---

<div class="post-metadata">

**Author:** ![GraemeWill14235](https://avatars.discourse-cdn.com/v4/letter/g/bbce88/32.png) [@GraemeWill14235](https://forums.knack.com/u/GraemeWill14235)\
**Post date:** [July 23, 2015, 8:13pm UTC](https://forums.knack.com/t/make-dismissing-a-modal-pop-up-by-clicking-outside-window-optional/9646/6 "2015-07-23T20:13:47Z")

</div>

Just experienced this 3 times when using a modal popup on an iPad. In fact at least once it closed when I actually clicked WITHIN the box, trying to click submit. So agree with Eric, needs attention, especially on touch screen. Thanks

---

<div class="post-metadata">

**Author:** ![Jessie](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/jessie/32/5_2.png) [@Jessie](https://forums.knack.com/u/Jessie)\
**Post date:** [July 16, 2021, 7:44pm UTC](https://forums.knack.com/t/make-dismissing-a-modal-pop-up-by-clicking-outside-window-optional/9646/7 "2021-07-16T19:44:06Z")

</div>

Yes, that’s our recommendation, thank you for adding that here!

```auto
/* Change the below scene_1 to the specific scene for your application or use `any` to enable for all scenes */
  $(document).on('knack-scene-render.scene_1', function(event, scene) {
    $('.kn-modal-bg').off('click');
  });

```

> **[JavaScript & jQuery Examples](https://docs.knack.com/docs/javascript-jquery-examples#prevent-modals-from-closing-with-a-click)**
>
> The following code examples have come from common requests, projects we've loved, code which users have shared with us, and other sources. Many of these examples showcase how easily jQuery can be leveraged to make considerable changes UX within your...
