Meteor - 如何在bootbox中使用Blaze.renderWithData并使结果保持被动?

时间:2016-04-18 21:29:08

标签: templates meteor meteor-blaze bootbox

我使用以下内容:

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

它呈现正确,但不是被动反应。

我怀疑直接传递文档时遇到问题,并且可以使用该文档的_id。

我应该将什么传递给renderWithData以使结果被反应?

2 个答案:

答案 0 :(得分:0)

如果在启动箱之前的代码中有doc = MyCollection.findOne(...),那么doc将被激活。否则,您可以传递_id并在模板助手中执行.find()(您传递给Blaze.render()的那个。

答案 1 :(得分:0)

我找到了解决方案。

而不是

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

或者

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

我切换到

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

现在这会使对话框反应。