How do I close A popup view with a button on it?

Hey Everyone,
I am new to this community and I have a question.
I have a popup view that I want to close with a button on it. How can I achieve this task?
I have recorded a short video which describes the workflow and issue.
Link of the Explanatory Video

I have a View "BrassTag" where I have a "Save" button, When I click it, it opens a Popup, this popup then Have another button. I want to close this popup and the "BrassTag" view when this "Button" is clicked. I have tried everything but unable to achieve it. Can anybody help me in figuring out the issue?

On your inner view (i.e. the one with "Button"), when you specify the ClosePopup event, you need to pass in the same popupId so that it knows which popup to close.

So, at 0:16 seconds into the video, you can see M62jlFBT as the popup ID. You need to copy that identifier into the Identifier field that's displayed at 0:42 - the action on "Button".

I usually don't open/close popups this way - usually I call system.perspective.openPopup and system.perspective.closePopup and that is how I'm inferring that the Identifier is what is misconfigured (you need to also pass an id when using the scripting equivalent).

2 Likes

Thank you so much, it worked like a charm. And Thank you for guiding me towards the right way of opening and closing the popups. I will follow the convention.

I didn't watch the video but I notice that you have two actions in the onActionPerformed event. Be aware that these operate asynchronously.

Many have got caught out by a Popup Close action executing before the preceding Script action has executed. You can avoid this problem by putting the system.perspective.closePopup instruction into the script after whatever else has to be done first (such as saving form data).

3 Likes

I'm not sure what you're calling the "right way", but opening popups with the built-in action is perfectly reasonable.

I'll suggest one thing: Pass the popup's id as a parameter to the view. This way, you can use that parameter to close the popup without having to hardcode the id into your view.

Also note that the popup id is actually used to build the element's DOM id, so if you control that id you can use it in the css stylesheet to greatly enhance the look and feel of your popups.

I even use it to "hack" themes on projects where I can't use actual theming.
ie: I make the popup's id start with {session.props.theme}, then I can target them with selectors like .ia_popup[id^=popup-light or .ia_popup[id^=popup-dark and apply different styles based on what theme was selected.

I guess what I'm trying to say is, pay extra attention to how you setup your popups, it can open up a world of possibilities.