2016-12-22 6 views
0

템플릿에 많은 그래프를 생성하려고합니다. 첫 번째 그래프는 기본값입니다. 영역을 클릭하면 다른 템플릿에있는 다른 그래프가 생성됩니다. 어떻게해야합니까?다른 템플릿의 html로 meteor에서 템플릿 본문을 어떻게 바꿀 수 있습니까?

다른 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]}; 
}}); 

답변

0

이 목적으로 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(); 
    } 
}); 
+0

이 코드 내 첫번째 그래프 변화 내 데이터를 할 때. 내 div 지정 jquery를 사용합니다. 고맙습니다! –