Forum Documentation Showcase Pricing Learn more

Update function runs twice when plugin placed inside repeating group?


#1

I am working on a plugin that manipulates repeating groups; however, when I place the plugin into the first cell, it always calls the update function twice for every cell. I am only logging to the console, yet it will log it twice for each cell, no matter how many cells there are. The console only logs once when I put it in the initialize function, as expected.

Is this a bug or something I am doing wrong?


#2

I have noticed the update gets called several times for a single change. Not sure what causes it, but it hasn’t caused any trouble for me yet. YET…


#3

Unfortunately, it’s bringing my current project to a halt. The div I create and append gets appended twice for each cell of the repeating group. Darn!


edit: I resolved by setting an instance.data variable to ‘false’ when the update code had yet to run, then updating it to ‘true’ once the code ran once


#4

There might be a more elegant solution, but might it be possible to prevent duplicates with a bit of logic - e.g. checking for the existence of the div before adding it or using the instance.data object to flag whether or not it’s already been added? Just a thought.


#5

Holy simultaneity, Batman! Seems like we posted within a fraction of a second of each other! :wink: