Passing data during events

I am trying to click on a photo element, and launch a modal that contains a bigger version of that photo, but I can't figure out how to pass the necessary data from one to the other.

Am I supposed to populate a variable as part of my event, and then retrieve that value on the other side?

Is there a hidden way to pass an object from one control to another that I'm not aware of?

I've been relying on using the table.selectedRow of the element I clicked on, but this falls apart in Collections and other controls that don't have selected elements.

Any guidance here would be awesome. This feels like a very solved problem, but I can't figure out what the recommended path is.

Hello @jeffblankenburg!

Good question, may I ask what type of data you are looking to pass? Is it the image URL or metadata related to the image?

The first thought I had would be to use javascript variables, you can set data to the variable on click and then access it for the modal.

You can use .setValue() function on the variable to give it an object, if you want to have the same variable be re-used then you would likely need to add some clearing logic on an event such as a modal close.

You can grab data from this variable from scripts that run on UI events as well as on query success. Hopefully that helps and let me know if you have any other questions!