Close all open pop-ups

0
I’m using the File Document Viewer in a pop-up (non modal) so it’s possible to view more files in a pop-up without closing the previously opened file. Now i would like to close all opened pop-ups in one click. Anyone has done this before? Maybe using javascript? I have searched the internet en tried some things but can get the solution.
asked
3 answers
2

It seems to be planned https://forum.mendix.com/link/ideas/21

answered
0

You can probably achieve this by downloading the HTMLSnippet widget from the store and then using jQuery: $('.yourButtonClass').click(function() { $( ".popupCloseButtonClass" ).trigger('click'); }); Add a class to a button '.yourButtonClass' and then use that to trigger a click on the close button of your popups 'popupCloseButtonClass'. I believe it should work if the close button on your popups have the same class.

answered
0

It's not possible to close multiple pages at once directly from Mendix (yet), but I’ve created a (hacky) workaround once, that could also work in your case.

- Create a non-persistent entity 'ClosePageHelper’ with a boolean attribute ‘ClosePage’ (default false) and link it to your Document

- on your pop-up page, add a dataview with datasource microflow, with a GetCreate for your ClosePageHelper

- in that dataview, add a MicroflowTimer widget that calls a microflow that closes the page, and make it conditional visible based on the ClosePage attribute. The microflow timer must be set to execute once and start at once.

- now, when you want to close your multiple FileDocument pop-ups at once, loop over them, calling the ClosePageHelper_GetCreate again, and set the ClosePage attribute to true and refresh in client, This will trigger the MicroflowTimer to become active on your pop-up and it will trigger the microflow to close the page.

answered