Wait on images in iron:router


#1

I have a small web app with about 60 documents in a collection. One of the fields is an image path. Is it possible to waitOn those images to load into the client before rendering the template? What’s the best way to preload images with meteor?


#2

just bumping this. anyone have experience preloading images with meteor?


#3

I’d like to know too! If anyone has the answer…


#4

I’m not sure if I understand your question right, but I think I had a similar problem today:

I got a console error, when I refreshed the page that contained my images.
Nothing was breaking, but I still got the error.

I found out that this was due to my image collection not being ready before rendering.
After some fiddeling around I found this in the iron router docs:

Router.route('/detailspage/:_id', {
  loadingTemplate: 'loading',

  waitOn: function () {
    return Meteor.subscribe('images');
  },

  action: function () {
    this.render('myTemplate');
  }
});

This worked for me.
Maybe it helps.


#5

What does the publish side look like?