我试图在一个模板上生成很多图,我的第一个图是默认的,我想当我点击一个区域时,我会生成另一个存在于另一个模板中的图。我怎么能这么做?
我试图用我的另一个grahp返回我的模板。
Template.test.events({'click .zone' : function (e){
console.log("J'ai cliqué sur le template Test ... on va essayer d'ouvrir une pop up");
e.preventDefault();
//$('#animalsModal').modal('show');
return {template: Template[createGraph]};
}});发布于 2016-12-23 13:12:13
为此,您可以使用Template.dynamic。
//html
<template name="graphDisplayer">
{{> Template.dynamic template=helperToGetDynamicTemplate}}
</template>//JS
Template.graphDisplayer.onCreated(function(){
this.templateNameOfGraph = new ReactiveVar('yourDefaultTemplate');
});
Template.graphDisplayer.events({
'click .zone':function(e,t) {
t.templateNameOfGraph.set('yourOtherTemplate');
}
});
Template.graphDisplayer.helpers({
helperToGetDynamicTemplate:function(){
return Template.instance().templateNameOfGraph.get();
}
});https://stackoverflow.com/questions/41287720
复制相似问题