Hi, I'm building an industry-specific calculator which calls an API every time a relevant input is changed in order to update the final values.
One of those inputs is a list of Things displayed in a Repeating Group. The reusable in the RG is just a button with dynamic text that deletes its corresponding Thing when clicked. I can call my endpoint and get the results whenever a user adds something to the list of Things by pressing a corresponding button outside of the RG, via 'This button is pressed', but I can't figure out how to trigger the same workflow whenever either the length of the list in the RG changes or when one of the Things is deleted.
My goal is to update the output labels with new data when a user removes a Thing from the RG.
Any assistance is greatly appreciated.
Can you create a custom event with the series of actions you need to happen each time the Thing is updated, and then trigger the Custom Event whenever the item is updated and/or deleted?
I’m doing this right now, admittedly without an API connection, but the updates work each time, including when one of the items in the RG is deleted.
I do have a custom event handling the call and data mappings. Triggering it upon deletion of a Thing/change in the RG’s contents is where I’m stuck.
@msgiblin are you triggering the deletion of Things with an element inside of a repeating group or outside of one?
I’m triggering the deletion with a button inside of the RG. That button’s workflow has steps to remove that thing from the list (parent thing), delete the thing, and to trigger the updated values custom event. By using the button inside the RG to trigger everything, I avoid any of the issues trying to reference RG items from outside the RG.
That would probably work for me if I only needed data from the Thing or the Repeating Group, but the business logic requires data from outside of the RG as well.
I’m tinkering with the idea of having a ‘selected’ custom state for the reusable in the RG so that if any of the Things in the RG are selected, a button that can delete the Things and then do the custom event.
Although I’m not exactly proud of it, my solution was to add a ‘selected’ property to the Things in question. With that property, items in the RG can be toggled as selected by tapping them and elements outside of the RG can search for Things that are selected=‘yes’. I’ve got a delete button that’s only visible whenever there’s Things that have selected=‘yes’ and only deletes Things that have selected=‘yes’.
It would be preferrable if the item in the RG could both delete itself and trigger an event coming from the RG itself, but this does prevent old/invalid data from being displayed in my use case.
This topic was automatically closed after 70 days. New replies are no longer allowed.