GlideModal closing

chi-kwong
Giga Contributor

Is it possible to prevent a GlideModal Window from closing when the user clicks outside of the window? Ie. I want to force the user to click within the Modal. The GlideDialogWindow natively seems to have this feature but it doesn't display as nicely and I can't pin the position of the Window centrally.

Thanks

1 ACCEPTED SOLUTION

LaurentChicoine
Tera Guru

Hi, there is a method for that:



var modal = new GlideModal('page');


modal.setBackdropStatic(true);



However this is not documented in the doc so it could eventually becomes unsupported without warning. I consider this as a not so important feature so you could put it in a try catch to make sure it does not break anything. So if it becomes unsupported, the modal window will simply return to old behavior of closing when clicking outside of window.



var modal = new GlideModal('page');


try{


        modal.setBackdropStatic(true);


}


catch(e){


        console.log(e);


}


View solution in original post

5 REPLIES 5

LaurentChicoine
Tera Guru

Hi, there is a method for that:



var modal = new GlideModal('page');


modal.setBackdropStatic(true);



However this is not documented in the doc so it could eventually becomes unsupported without warning. I consider this as a not so important feature so you could put it in a try catch to make sure it does not break anything. So if it becomes unsupported, the modal window will simply return to old behavior of closing when clicking outside of window.



var modal = new GlideModal('page');


try{


        modal.setBackdropStatic(true);


}


catch(e){


        console.log(e);


}


Hey Laurent,



Great answer.



I too scratched my head over this in past, and settled with DOM.



How did you figure out this undocumented function? In general, is there a reference link that provides you with all these undocumented functions?



Regards,


Anurag


It's a client side object so you actually have access to all that code inside javascript files that are loaded on the form (when you are on the form).



What I usually do is open the form outside of the frame (easier to work without iframe) in chrome is open developer tool and look for the object I'm interested in (CTRL + SHIFT + F). Then I locate the result with the constructor, in that case it looks like this:



GlideModal.prototype = { ...



Inside of the object you have all the available function defined, usually naming is pretty explicit but some time I dig in to find out what the function is actually doing.



When I have trouble finding the file, I use the console. For example in that case:



  1. var modal = new GlideModal('test'); //Press enter to create the modal object in the window scope
  2. Type "modal." and the developer tools of the console should offer you the available functions.

Wow, thanks buddy. Learnt a new thing today