Can't close a GlideModal window

Ken83
Mega Guru

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.

find_real_file.png

find_real_file.png

8 REPLIES 8

ScienceSoft
Tera Guru

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?

xiaix
Tera Guru

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?

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.

 

 

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":

find_real_file.png

It still works because the "X" close button element is still on the page (just not visible).

UI Page name:

find_real_file.png