I’m sure I’m doing something very wrong and silly.
I am rendering a page. It shows a list of images. To ensure they are lazy loaded, I’m using the unveil.js jquery plugin (checks if an image is in viewport and swaps a data-src value into the image src
).
On initial page load, it works great. I see images. Then I change a reactive session var to let the user switch “categories” — this causes the image collection to change.
Except no images appear, because the re-render means the new set of image values are stuck in data-src
. I need to re-run unveil.js after the DOM change.
How on earth is this done in Meteor? How do I know when the Session variable has changed? Or when the image collection has changed? Or the template finished changing (so onRendered
is not an option).
(And no, I can’t re-run unveil when I set the Session — that could be a split-second before the DOM actually changed.)
STOP THE MADNESS!