OEMR 5.0.1 using the dlgopen and dlgclose functions


I am trying to use these for a project that requires cascading popups. Basically window A opens window B, which opens window C to search for something. After window C has successfully closed, window B can no longer close using dlgclose and a callback function, it no longer has a defined ‘opener’. If window C is not called, window B can close and reference the callback function just fine though. Is there something I might be missing in creating my iframe/popups with dlgopen, and it’s losing track of which is which? I am using the new OpenEMR\Core\Header and typically setting up ‘opener’ and ‘dialog’, sometimes more if needed. I can also provide more information, but didn’t want to start with a novel. This is 5.0.1 with the latest patch (7). I can put snippets of code in where they are called and closed too if that would help -

(Jerry P) #2

You have to ensure each dialog has unique id (if one is not set in call, an unique will automatically be assigned). Also ensure each script being called by dialog includes ‘opener’ in Header or include_opener called directly. There are several places in openemr that use cascading dialogs such as appointment events etc. Unsure how reliable dlgclose() is in cascades and with newer browsers, cross site is issue with window close but closing either way should not be an issue if using a callback in opening script.I don’t believe dlgclose() uses window.close() but it’s been awhile since developing so i’m unsure.


Hey Jerry - I did get it working, I found a typo (it’s so embarrassing, I will wear start wearing glasses more while at work I guess) that was most of my problem, and I am pretty sure that using the dlgopen libraries wipe out the window.close by redefining it, but the dlgclose works well. I did get my cascading sequence working well, thanks again!

(Jerry P) #4

@rgenandt Great to hear. dlgopen() has become a little tricky due to the many different scopes the darn thing gets called and needs to be turn into a library however, starting with v5.0.3 we are removing the Frames UI and one of the goals for UI is to remove dialogs unless absolutely necessary. As you may know dialogs on smaller devices, responsive or not, are just aggravating.

Take a look at interface/main/tabs/js/include_opener.js to see how dialog gets closed. window.close() is redefined there.