I have a component which writes/generates javascript from a server side renderer. This component can be used in multiple times in a same page. However, once the page is loaded I have to collect all the variables or JSO written by this multiple components in the page. How can I do this so that I will have a collection of all the variables or JSO? For e.g. If this component (lets say ) is used twice in the page then it emits two javascript block on client/browser – var arr1 = new Array[‘First’, ‘Second’] and var arr2 = new Array[‘Third’, ‘Fourth’].
In order to make a final rendering I have to combine these two arrays.
You will need to be a little more specific about your problem, maybe with an example page but here are some thoughts.
If you have a server-side component that writes JavaScript during page generation, I would generate a function call each time, something like:
then ensure that you have your function
Component_appendArray()defined before these calls:At the end,
globalArrayshould contain:Hope this helps.