Displaying popups and passing data from them

Does anyone have a solution for displaying popups, passing data to them, and then passing data from them while closing the popup? I’ve tried literal popups and embedded views and can’t find a way to pass data back to the original view’s parameters.

Popups will not “pass” parameter values because they are independent of the Page/View which opened them (they remain open if you navigate somewhere else).

That being said, there are several ways to provide data present in a popup so that it may be consumed by something else (assuming these are values which are changing within the popup).

  1. bi-directionally bind the desired value in the popup to a custom session property. This will allow anything in your project to bind against that value. This does require that the property already be in place and therefore have a default value, and it will retain values for the life of the session, so not a great idea in some cases.
  2. place a propertyChange script on the relevant components, and use system.perspective.sendMessage() (docs) to essentially broadcast the new value to listeners. This obviously requires that you configure listeners for any property you need to “subscribe” to in the Popup, but it’s accurate and doesn’t persist like the session properties solution would.
  3. If you only need the data on Popup CLOSE, then if you make your own button to perform the close action you could bundle all of the data and broadcast a single message in the button’s onClick Event, something like the following code would work great, but also would require that you pass the Popup a unique ID when it gets opened. This method would allow for a single broadcast (sendMessage invocation) and single configured listener.
system.perspective.sendMessage(messageType='DATADUMP',payload={'name':self.root.getChild('NameTextField').props.text, 'user_id':self.root.getChild('UserIDNumericEntryField').props.value},scope='page')
1 Like