Get the path to a popup page

I am working on a way to log page visits, this related to the Mendix path in the studio pro. I’m using the Javascript-snippet to get this done. for a full screen page (Atlas_Default) i retrieve the path like this: let pageName = mx.ui.getContentForm().path wich returns me a string holding the path: ModuleName/ like:  MyFirstModule/ so far this works fine, i do a string split on the first ‘.’ wich results in ModuleName/PageName  The problem comes for a Popup page. When using the same code,  i get the path to the underlaying full-screen page (ModuleName/PageName), and not the wanted path to the popup page (ModuleName/PageName_Popup).   Anyone has an idea how to get the path to a popup page by the Mendix Client Api’s
2 answers

Inside the a widget / javascript snippet you can access the information



For anyone trying to find the pop up form in a Javascript action (where you don’t have this context of a widget), to be able to use the call of a widget like Andries is mentioning above, you first need to find the relevant widgets that are in the pop up.

After playing around with the Client API functions that are non documented I found a function that returns all widgets on a page and you can then loop over those to find the ones that have widget.mxform of a pop up.

I did something similar to this:

// this gets all widgets on the page
var listOfWidgets = mxui.widget.getDescendantWidgets(document);

// empty list for forms
let forms = new Array;

// create list of forms (which you can use to find the pop up form)
for(let i = 0; i < listOfWidgets.length; i++) {
    // this is the call that Andries is referring to

To identify the ‘current pop up’ I did a comparison of the DOM positions of the forms in the list using this: