Darshan Hiranandani : How can I update my JavaScript file with new content data when items are added dynamically?

Hi team,

I’m facing a challenge with dynamically updating a JavaScript file when new items are added to a repeater. Each item has a title and a description, and I need to ensure that this data is available to my JavaScript as soon as new items are added.

Currently, I’m using wp_localize_scripts to pass data to the JavaScript, but it doesn’t seem to update with the new content dynamically.

Could anyone provide suggestions on how to effectively pass and update data in JavaScript when items are added dynamically?

Your input on these questions would be really valuable. Thanks in advance for your help!

Regards
Darshan Hiranandani

You are going to have to explain what exactly you are trying to do. wp_localize_scripts seems to be a WordPress function. Are you running an embedded WordPress site in your app?

Are you using raw JavaScript or a JS Framework like Vue/React/Angular?

Providing an example/sample of what you are trying to do would also be helpful.