【发布时间】:2016-10-22 14:53:44
【问题描述】:
我想使用 Meteor 将一些数据从模板共享到另一个模板。我有一个模板,即 allInventory.html,我在其上以表格形式显示一些数据,我在那里添加了三个链接。一个用于查看、编辑和删除我想要的内容,我将所有数据从后端获取到帮助程序之一,即 productDetails,我将一个事件与查看按钮绑定,该按钮将获取当前用户点击哪个产品的数据,因此我已成功获取数据在我的 allinventory 模板中,但还有另一个模板,即我想在其上呈现或显示该数据的 productDetails。但坚持认为我有关于 allInventory 点击事件的数据,但不知道如何与 productDetails 模板共享相同的数据。
这是我的 allInventory.js
Template.allInventory.rendered = function() {
Template.allInventory.events({
"click .btn":function (e){
data = $(e.target).attr('data');
Router.go('productDetail', {data: $(e.target).attr('data')}, {query: 'q=s', hash: 'hashFrag'});
console.log("button clicked.."+data);
console.log(data);
}
})
ProductDetails.js
Template.productDetail.rendered = function () {
Template.productDetail.helpers({
productDetails: function() {
return data;
}
});
allInventory.html
<button type="button" data ="{{productInfo}}" class="btn btn-info btn-sm"><i class="fa fa-eye"></i>View</button>
我只是想与 productsDetails 模板共享 allInventory 模板数据。
如有任何帮助,我们将不胜感激! 谢谢
【问题讨论】:
标签: node.js templates meteor meteor-blaze