Render once I have the data

Hi guys:

Im using selectpicker control to load some dropdownlist.

I have realized that these DDL are loaded emtpy sometimes, I believe because it renders when there is no data yet…so, how can i make sure that i have the collection data before rendering ??

At the moment Im using a timeout, but I think that maybe is not so elegant this solution …

//js code:

function renderO(){

Template.searchbox.onRendered(function() {

this.autorun(function© {
if (Operaciones.find().count() > 0) {


//html code

{{#each operaciones}}

Is there another way to make that I have the data before rendering? Do I missing something?

thanks a lot…

You are looking at this in a traditional jQuery way. You should be looking at it in a Meteor way, where the select is built reactively.


<template name="picker">
    {{#each options as option}}
      <option value="{{option.value}}">{{}}</option>


Template.picker.onCreated(function() {

  options() {
    return OptionsCollection.find();


Meteor.publish('picker', function() {
  return OptionsCollection.find( someSearchCriteria );

That example uses a Mongo.Collection for the picker options. You could use a REST endpoint, or something else equally well.