Is there a way to programmatically add item to a repeater?

I have a section with a repeater. The section also has a header action. When the action button is click, im doing something in the background and then create an item in the repeater. Could someone point me to the right direction. TIA!
6 Replies
toeknee
toeknee2mo ago
You can set the data for the repeater with the Get/Setting methods. You could try setting traversly? so $set('../../my_field', [data])
sirking
sirking2mo ago
great! I'll try that out Thanks @toeknee
sirking
sirking2mo ago
okay, that would set the field of the repeater. My goal is to create Chapter when the "Ask AI to generate chapters" button is click
No description
toeknee
toeknee2mo ago
I am not familiar with the actions in this scenario, but you should be able to set the chapters by setting the field? so say you have chapters:
$set('../../my_field', array_merge($get('this_repeater'), [['title' => 'tony chapter', 'description' => 'is amazing']]));
$set('../../my_field', array_merge($get('this_repeater'), [['title' => 'tony chapter', 'description' => 'is amazing']]));
sirking
sirking2mo ago
Thanks again @toeknee hi @toeknee in your example above, the my_field is the id of the repeater?
toeknee
toeknee2mo ago
yeah
Want results from more Discord servers?
Add your server