Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates Meteor如何在模板末尾加载脚本_Templates_Meteor_Handlebars.js - Fatal编程技术网

Templates Meteor如何在模板末尾加载脚本

Templates Meteor如何在模板末尾加载脚本,templates,meteor,handlebars.js,Templates,Meteor,Handlebars.js,我有一个像这样的模板。它过去用于处理常规html文件,但现在不起作用 这是我的test.html文件 <template name="test"> <a href="xxxxxxxx" class="screenshot"> <img src="xxxxxx" alt="Screenshot" class="thumbnail"/> <span class="screenshot-zoom"></span> </a

我有一个像这样的模板。它过去用于处理常规html文件,但现在不起作用

这是我的
test.html
文件

<template name="test">
<a href="xxxxxxxx" class="screenshot">
    <img src="xxxxxx" alt="Screenshot" class="thumbnail"/>
    <span class="screenshot-zoom"></span>
</a>
<script>
    $(function () {
        $(".screenshot").lightbox();
    });
</script>
</template>

$(函数(){
$(“.screenshot”).lightbox();
});
EDIT1

我遵循并尝试了类似的测试,但仍然不起作用

->test.html
<template name="test">
    <a href="./img/screenshots/placeholder.gif" class="screenshot">
        <img src="http://placehold.it/300x120" alt="Screenshot" class="thumbnail"/>
        <span class="screenshot-zoom"></span>
        {{add_my_special_behavior}}
    </a>
</template>

->screenshot.js
Template.test.add_my_special_behavior = function () {
    Meteor.defer(function () {
        // do stuff to it
        $(".screenshot").lightbox();
    });
    // return nothing
};
->test.html
->screenshot.js
Template.test.add_my_special_behavior=函数(){
Meteor.defer(函数(){
//做点什么
$(“.screenshot”).lightbox();
});
//一无所获
};
使用模板可用的事件:

Template.test.rendered = function() {
  $(".screenshot").lightbox();
}

这将在Meteor渲染模板后执行lightbox方法。

检查this@crapthings谢谢我试过了。但它似乎不起作用。脚本加载顺序