Can't close a GlideModal window
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-13-2018 07:43 AM
Hello Community,
I've been checking every article I can find about this issue on the community but I've had no success. My goal is simple...CLOSE THE GLIDEMODAL! That's all I really want to do. To be clear, I have the X in the upper right corner of the modal dialog. That successfully closes the popup. That's not a problem. I have a button in the dialog that I want to close the dialog when it's clicked. Nothing I do from within the dialog is closing it.
I'm getting the error that GlideDialogWindow is not defined or GlideModal is not defined or cannot read property destroy of undefined or cannot read property get of undefined. I don't know what else to try here. Suggestions? Here is my code in its current state.
- Labels:
-
User Interface (UI)
- 7,441 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-13-2018 02:34 PM
Perhaps, GlideDialogWindow is not accessible object in your scope - you need to reach the proper scope and find GlideDialogWindow object first and then you'll be able to close it.
Are you using fames or nested UI Page?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-12-2019 02:36 AM
In my UI Page code, I do this:
<button onclick="GlideModal.get().destroy()">Cancel</button>
... but that's because I constructed it with GlideModal. Did you do the same?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-01-2019 03:34 PM
I tried it:
<button id="btnYes" onclick="GlideModal.get().destroy()">OK</button>
but did not work, this is the error:
TypeError: GlideModal.get is not a function
Were you able to find other solutions?
Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-02-2019 04:41 AM
Yep, I too am getting that same error, so here was my final solution:
function closeGlideModal() {
try {
GlideModal.get().destroy();
}catch(err){
console.warn("closeGlideModal ERROR: "+err.message);
var x = document.getElementById('srs_change_application_closemodal');
if (x) {
x.click();
} else {
console.warn("No 'X' close button found!");
}
}
}
on the line: var x = document.getElementById('srs_change_application_closemodal');
just make sure that your using the UI Page "name", followed by "_closemodal".
Oh, and the beautiful part about it is that even if you set this second parameter to "true":
It still works because the "X" close button element is still on the page (just not visible).
UI Page name: