I am currently working on developing a simple application that dynamically displays thumbnails and connects a generated modal to each one upon clicking. I am facing difficulty in integrating data from my mongo db into the bootbox alert. Although I understand that I need to execute the query again, I am unsure about how to fetch the fields for that particular entry.
Below is the HTML template:
<template name="gallery">
<div class="col-xs-6 col-sm-6 col-md-2">
<a href="#" class="thumbnail" data-toggle="#">
<img src="{{img}}" alt="...">
<div class="caption">
<h5><center>{{name}}</center></h5>
</div>
</a>
</div>
</template>
and here's the js.
Gallerys = new Mongo.Collection("gallerys");
if (Meteor.isClient) {
// This code only runs on the client
Template.body.helpers({
gallerys: function () {
return Gallerys.find({}, {sort: {createdAt : -1}});
}
});
Template.body.events({
"click a.thumbnail": function(e) {
bootbox.alert(function(){
return Gallerys.find();
};
}
});
}