I’m populating a template with data using Blaze.renderWithData()
, but how can you make it reactive so when the underlying data changes, it is reflected in the template reactively. This is how the template is rendered with data:
var myContainer = document.getElementById('myContainer');
var keyImg = $(event.currentTarget).closest('.shadow').find('.imgRef').val();
var keyUser = $(event.currentTarget).closest('.shadow').find('.imgRef1').val();
Meteor.call('getDetailsUser',keyImg,keyUser, function(err,result){
if(err){
console.log(err.reason);
return;
}
Blaze.renderWithData(Template.see,result,myContainer);
});
getDetailsUser: function(key,user){
if(Meteor.user()){
getUser = Meteor.users.findOne({$and:
[{_id: user}, {'ImagesUploaded.key':key}]
});
getUser.ImagesUploaded.forEach(function (items)
{
if (items.key===key){
image = items;
}
});
return image;
}
}
Otherwise new data is only displayed on refresh.