Close popup automatically

Using perspective, I have a popup that comes up. It is in the Views folder with the actual popup view in Popups/NavDropdown. It is a navigation popup that comes up and I want to automatically close the popup once they press one of the navigation buttons. It is not working. What am I doing wrong?

You shouldn’t mix Actions which are dependent on timing, because all of the attached actions for an Event are run asynchronously - meaning they can start/complete out of order (or maybe not at all if a reference to the page is pulled out form underneath them).

Regardless, the issue stems from your use of closePopup. That function requires the id of a popup if you’re targeting a specific popup, but it can also accept an empty string if you just want to close the most recently opened Popup.

So you have two options in your current Script:
A. Instead of supplying the viewPath in use, you need to specify the identifier of the popup which is displaying your navigation buttons.
B. Instead of supplying the viewPath in use, you need to supply an empty string ("").

If you want to supply the identifier, you should look at the Popup action you used to open the popup (the identifier field is half-way down and to the left):

Or if you used a script, then you want the id argument you supplied:

system.perspective.openPopup(id='ThisIsTheValueYouWant', view='Popups/NavDropdown')

Related question: can you read the popup’s id once it’s open? I’ve been writing the popup id into a popup param in order to use it to close the popup, but wondering if there’s a cleaner way?

No, this is absolutely the way I personally recommend. If you haven’t been doing that and only have an idea that a Popup is open but no way to identify it, then you should use the empty string option.