【发布时间】:2015-04-21 03:57:03
【问题描述】:
我正在尝试创建一个基本应用程序,该应用程序可以动态呈现缩略图并将动态生成的模式关联到每个点击。我似乎无法弄清楚如何将我的 mongo db 中的数据插入到引导箱警报中,我知道我需要再次运行查询,但我不确定如何检索该特定条目的字段。
这是 html 模板:
<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>
这是 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();
};
}
});
}
【问题讨论】:
标签: javascript mongodb meteor bootbox