Search code examples
templatesmeteormeteor-blazebootbox

Meteor - How to use Blaze.renderWithData in a bootbox and have the result remain reactive?


I am using the following:

let box = bootbox.dialog({title:'',message:''});
box.find('.bootbox-body').remove();
Blaze.renderWithData(template,doc,box.find(".modal-body")[0]);

It renders correctly, but is not reactive.

I suspect I have a problem passing in the doc directly, and have the _id of the doc available.

What should I be passing to renderWithData in order for the result to be reactive?


Solution

  • I found my solution.

    Instead of

    let doc = MyCollection.findOne({_id});
    Blaze.renderWithData(template,doc,box.find(".modal-body")[0]);
    

    Or

    Blaze.renderWithData(template,MyCollection.findOne({_id}),box.find(".modal-body")[0]);
    

    I switched to

    Blaze.renderWithData(template,function(){
      MyCollection.findOne({_id})
    },box.find(".modal-body")[0]);
    

    This now makes the dialog reactive.