Hi, I’ve got a problem which I didn’t found an answer so far…
I have a popup (form to create a new thing) which i use in different pages (all pages are reusable elements themselves).
I thought to make this form as a reusable too, which works, BUT I need to add this new data thing into a parent data type which hold these in a list.
And thats the point I wonder if its possible to solve at all…
Let the popup has the list which the new thing should added too as a custom state. I wanted to add the new thing to the custom state’s list which does not work, because I need to “change a thing…”
A thought about let the parent data instance to be a custom state of the popup - Problem: I have more than 1 (parent) data types which all hold lists of my newly created one…
What I thought/ wish for:
Let my reusable popup create a custom event, lets call it ‘data saved’ which I can trigger after I created the new data thing.
The parent elements, which hold and control the reusable popup can listen to this ‘data saved’-event and than can make changes to the parent data things to add the newly created one into the lists… Is this possible? In objective programming I would refer to it as a delegate.
Hope my points are clear; thx!
Yes - using a custom event within a reusable is a very powerful way of managing workflows because of the workflow action “trigger a custom event from a reusable element.” You can have various custom states each with a matching custom event, and use that setup to pass data between reusables.
It really is a pain to send information back to parents. The only way for a popup parent element to know that it was “done” is using the “close” method that is called everytime the popup closes. What I do, I create every objects as variables on the popup and set them using “trigger a custom event from a reusable element”. Then there is an extra state that refers to the state of the popup (ok, canceled) prior to “close”. The parent is looking for the “close” event and then he looks up into the state and, if it is ok, it performs whatever the parent needs to do. He may also make a final call to the reusable object that may do its own stuff.
Unfortunatly, there is no clear way to communicate out of a (non popup) reusable element. But there is this great plugin called antena/satellite that works fine and allows you to communicate any element to any element where the antena/satellite pairs exists. Really cool and intersting.
Didn’t got it working with Antenna/Satellite approach, but I’m using, as you said, the
a popup closed - event to get the state out of the reusable child (if a flag was set to yes).
This topic was automatically closed after 70 days. New replies are no longer allowed.