Thanks for the feedback Ankur, I tried a few more things and this seems to be a bug of some sort:
So, in my plugin editor, let’s say I create 2 elements: element1 and element2.
In each of the elements, under the element code in each of the headers, I initialize the same window.variable = [] with a different value: in element1, window.variable[0]+=1 and in element2, window.variable[1]+=1.
Now, when I run the plugin, assuming I only have element1 and element2 added once each, I correctly get: window.variable = [1,1].
However, if I were to add the same element1 (or element2), on the page, it seems to not run the html code again:
So, I get window.variable = [1,1], while I should get [2,1] as in, it should rerun the element1 initialization code, however, it seems to only run it once irrespective of the number of element instances.
so, it would do something like:
- Header code of first instance of element1
- Header code of element2 (this updates correctly the same variable)
- Does NOT run header code of second instances of element1
then the remaining flows:
- Initialize code of element1, update code of element1
- Initialize code of element2, update code of element2
- Initialize code of the second element1, update code of second element1
Did anyone face a similar issue when trying to add the same element multiple times to a page and when you need to concatenate or merge the values of both elements in your code?
Note: Although the initialize and update codes do run for each instance of any element, I am unable to use those as they get executed one after the other, what I am aiming for is to initialize a variable that “counts” the number of elements present in the page and then use it as a condition in the “update” of each element.
Thanks a lot