# Toggling between popups

**URL:** <https://forum.inductiveautomation.com/t/toggling-between-popups/95538>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [September 4, 2024, 4:55pm UTC](https://forum.inductiveautomation.com/t/toggling-between-popups/95538 "2024-09-04T16:55:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriel\_Iglesias](https://avatars.discourse-cdn.com/v4/letter/g/e95f7d/32.png) [@Gabriel\_Iglesias](https://forum.inductiveautomation.com/u/Gabriel_Iglesias)\
**Post date:** [September 4, 2024, 4:55pm UTC](https://forum.inductiveautomation.com/t/toggling-between-popups/95538/1 "2024-09-04T16:55:45Z")

</div>

Hi, I have a popup that opens whenever I right click on a valve. These valves are displayed on my view as embedded views. By passing a different identifier to each embedded view, it is possible to open multiples popups. However, I want to be able to toggle between these popups, as the following sequence describes: Right click on the first valve, and the popup opens. Then right click on another valve, and have that popup to close, and open a new one.

Using the toggle tool and giving each valve the same identifier helps, but two clicks are needed in order to have the popup toggle at all, since the first one closes the first popup, and the second one opens the new one.

I could use some help! Thanks in advance,

Gabriel.

---

<div class="post-metadata">

**Author:** ![hw79](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@hw79](https://forum.inductiveautomation.com/u/hw79)\
**Post date:** [September 4, 2024, 5:15pm UTC](https://forum.inductiveautomation.com/t/toggling-between-popups/95538/2 "2024-09-04T17:15:51Z")

</div>

you could use `system.perspective.sendMessage()` and have the popup listen for it and call `system.perspective.closePopup()` when it receives the message. If you put the sendMessage before opening the new popup in the right-click script all the existing popups with the listener should close.

---

<div class="post-metadata">

**Author:** ![Gabriel\_Iglesias](https://avatars.discourse-cdn.com/v4/letter/g/e95f7d/32.png) [@Gabriel\_Iglesias](https://forum.inductiveautomation.com/u/Gabriel_Iglesias)\
**Post date:** [September 4, 2024, 5:34pm UTC](https://forum.inductiveautomation.com/t/toggling-between-popups/95538/3 "2024-09-04T17:34:43Z")

</div>

Thanks for your reply.

That implementation worked perfectly. The only question I have, is to why this does not work when the identifier of the popup is unique. Is it that the popup action runs before the script finishing?

Thanks again.
