我正在尝试渲染数据(来自模板),例如隐藏(当单击后退按钮时)并在同一HTML页面上显示(当单击视图按钮时)。我的代码如下:
<h2>Saved Deals</h2>
<p>This includes deals which are in draft</p>
<p><a class="btn btn-black fjalla" id="viewsaveddeals" role="button">View »</a>{{> saveddeals}}</p>
答案 0 :(得分:0)
您可以使用Meteor Sessions
,例如:
if (Meteor.isClient) {
Template.deals.helpers({
showSavedDeals: function () {
return Session.equals('showSavedDeals', true);
}
});
Template.deals.events({
'click #viewsaveddeals': function () {
Session.set('showSavedDeals', true);
}
});
Template.deals.onDestroyed(function () {
Session.set('showSavedDeals', null);
});
}
<template name="deals">
<h2>Deals<span>12</span></h2>
<p>This includes deals which are in draft</p>
<p><a class="btn btn-black fjalla" id="viewsaveddeals" role="button">View
»</a>{{#if showSavedDeals}}{{> saveddeals}}{{/if}}</p>
</template>
<template name="saveddeals">
<h2>Saved deals</h2>
</template>