<p>By default, Garnish.Modal will automatically close other modals when <a href="https://github.com/pixelandtonic/Garnish/blob/master/Source/classes/Modal.js#L91" rel="nofollow"><code>show()</code></a> is called (which happens automatically when you first create it).</p>

<p>That behavior can be overridden by setting the <code>closeOtherModals</code> setting to <code>false</code>, though:</p>

<pre class="lang-js prettyprint-override"><code>var myModal = new Garnish.Modal($container, {
    closeOtherModals: false
});
</code></pre>

CC BY-SA 3.0
2014-08-13T15:33:32.173Z
Thanks, problem is the forms.elementSelect (users) window is the one causing the conflict. I open my window, click add user and it opens the user select window and hides my orignal. So when I close user select, my 1st window is gone.

For now I'll probably just move this to another template and not to a modal.
Adam McCombs
CC BY-SA 3.0
2014-08-13T14:16:30.867Z
2014-08-13T14:16:30.867Z
Brandon Kelly
<p>Is there a way to override Garnish.Modal? </p>

<p>For example, I have a custom modal which uses a custom form but I want to be able to use the built in forms.elementSelect to select from a user list. When I select a user and press "select" it closes both my custom modal and my user select window. </p>

<p><strong>Can I override this to just close the most recent modal?</strong></p>

<p>This is in reference to Custom Modals inside Plugins: <a href="https://craftcms.stackexchange.com/q/374/45">How can my plugin generate a generic modal window in the Control Panel?</a></p>

<p><strong>Edit:</strong> It looks as if Garnish hides any other modals before loading a new one.</p>

<plugin-development><modal><garnish>
Possible to override Garnish.Modal? [Plugin]
# Possible to override Garnish.Modal? [Plugin]

(Asked by: username_0 on 2014-08-12)

Is there a way to override Garnish.Modal?

For example, I have a custom modal which uses a custom form but I want to be able to use the built in forms.elementSelect to select from a user list. When I select a user and press "select" it closes both my custom modal and my user select window.

**Can I override this to just close the most recent modal?**

This is in reference to Custom Modals inside Plugins: [How can my plugin generate a generic modal window in the Control Panel?](https://craftcms.stackexchange.com/q/374/45)

**Edit:** It looks as if Garnish hides any other modals before loading a new one.

**Tags:** plugin-development, modal, garnish


---

## 1 answers

### Answer by username_1 on 2014-08-13. Score: 1 | Accepted answer

By default, Garnish.Modal will automatically close other modals when show() is called (which happens automatically when you first create it).
That behavior can be overridden by setting the closeOtherModals setting to false, though:
var myModal = new Garnish.Modal($container, {
    closeOtherModals: false
});

> **Comments:**
> **username_0**: Thanks, problem is the forms.elementSelect (users) window is the one causing the conflict. I open my window, click add user and it opens the user select window and hides my orignal. So when I close user select, my 1st window is gone.  For now I'll probably just move this to another template and not to a modal.  

---

