[英]Meteor render template if parent has class
Hi there I am just wondering. 嗨,我只是想知道。 I have a series of collapsible divs from materialize.
我有一系列实现的可折叠div。 What I am trying to is if the table header is active render the template.
我要尝试的是如果表头处于活动状态,则渲染模板。 I am using a meteor handsontables package.
我正在使用流星表包。 SO i want the tables to render when active.
所以我希望表在活动时呈现。 SO what i have is.
所以我有。
<ul class="collapsible" data-collapsible="accordion">
<li>
<div class="collapsible-header"><i class="material-icons">filter_drama</i>Global What Ifs</div>
<div class="collapsible-body">
{{#if isActive}}
{{>GlobalWhatIf}}
{{/if}}
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">place</i>Second</div>
<div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">whatshot</i>Third</div>
<div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
</li>
</ul>
AS you can see I only have one template loading at the moment but I do plan on having quiet a few. 正如您所看到的,目前我仅加载一个模板,但是我计划保持安静。
Then my js 然后我的js
Template.CompanyDetails.onRendered(function(){
$('.collapsible').collapsible();
});
Template.CompanyDetails.helpers({
isActive: function(event) {
return true;
}
})
Template.CompanyDetails.events({
'click .collapsible-header' : function(event, template){
console.log(event.currentTarget);
}
});
I thought maybe I could pass the event target someway in the helper but does not seem to work. 我以为也许可以在帮助程序中以某种方式通过事件目标,但似乎没有用。 Is there someway I can check straight from the handle bars.
有什么办法我可以直接从车把上检查一下。
Any way some help would be great. 无论如何,一些帮助将是巨大的。
Something like this might work: 这样的事情可能会起作用:
Template.CompanyDetails.onRendered(function(){
$('.collapsible').collapsible();
});
Template.CompanyDetails.helpers({
isActive: function() {
if(Session.get("event")){
return true;
Session.set("event",undefined);
}
}
})
Template.CompanyDetails.events({
'click .collapsible-header' : function(event, template){
console.log(event.currentTarget);
Session.set("event",event);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.