I have a meteor template rendering some html that I need to perform a jquery function on. Right now, I've set up a dependency so that every time the data (a list of objects) tied to that template changes, the function runs. I'm not at all sure this is the best way to do what I'm trying to do, but it does run the function every time I add/delete/rearrange objects, so that's a start.
However, the function seems to be running before the template is re-rendered, so the previous set of blocks get jquery-fied, but any blocks I've just added on that action do not.
Is there a way to force a function to run AFTER a template is rendered/updated? Any help is much appreciated!
(similar question here -- Meteor reactive jquery -- but it doesn't have any answers)
Here are some maybe-relevant code bits:
Template.showPictures.rendered =
Deps.autorun () ->
album = Albums.findOne(Session.get("selectedAlbum"))
if (album)
pictures = album.orderedPictures()
MyApp.loadJQuery()
Template.showPictures.helpers
pics: ->
MyApp.myDependency.depend()
album = Albums.findOne(Session.get("selectedAlbum"))
album.orderedPictures()
(Why is the autorun in my Template.rendered thing? Not sure. That seemed like an okay place to put it, but this is my first time really dealing with dependencies, so I could be totally off-base here. Any ideas whatsoever on what's going wrong would be excellent.)