Meteorjs在模板中加载html脚本资源(不在主体中)

问题描述:

我使用jsplumbtoolkit框架来将几个脚本html模板加载到我的meteorjs应用程序中,以创建必要的适当的div /对话选项作为API。经过一些故障排除后,我确定问题似乎是Meteorjs没有通过我提供的onRendered函数加载我的html脚本。Meteorjs在模板中加载html脚本资源(不在主体中)

为了给你的问题的一个更好的主意

//由于Meteorjs不能直接在模板中加载脚本,我加入了脚本加载到我的onRendered功能在我的模板的js

Template.mytemplate.onRendered(function(){ 

    $(document).ready(function() { 
     var script = document.createElement("script"); 
     script.type="text/x-jtk-templates"; 
     script.src = "templates/workflowtemplate.html"; 
     $("#rulesscripttemplate").replaceWith(script); 
    }); 
}) 

workflowtemplate.html位于相应的meteorjs目录/public/templates/workflowtemplate.html中,我假定该目录是正确的。

这是正确加载,当我检查我的客户Mozilla开发工具包以及

<script type="text/x-jtk-templates" src="templates/templaterulesworkflow.html"></script> 

有没有更好的方式来确认此资源已通过逸岸Mozilla浏览器加载到客户端?

想通了。必须将<script type="text/x-jtk-templates" src="templates/templaterulesworkflow.html"></script>添加到我的应用程序的标记中。这解决了这个问题。