jquery lightbox 不适用于 Meteor
jquery lightbox is not working with Meteor
灯箱曾经工作过。但是,当我在流星上尝试时,它不再起作用了。
我首先添加jquery依赖项,并将jquery.lightbox.js和jquery.lightbox.css放入客户端文件夹。
$ meteor add jquery
$ ls -l client/js/jquery.lightbox.js
$ ls -l client/css/jquery.lightbox.css
这是使用灯箱的测试模板和脚本。
->test.html
<template name="test">
<a href="xxxxxxxx" class="screenshot">
<img src="xxxxxx" alt="Screenshot" class="thumbnail"/>
<span class="screenshot-zoom"></span>
</a>
</template>
->screenshot.js
$(function () {
$(".screenshot").lightbox();
});
如果我将其用作常规 html,它就可以工作。但它不在流星之下。我错过了什么吗?
从 Meteor 0.4.0 开始,您可以使用 Template.myTemplate.rendered
方法来执行此操作:
在您的情况下,那将是
Template.test.rendered = function() {
if(!this._rendered) {
this._rendered = true;
$(this.find(".screenshot")).lightbox();
}
}
这是我从 Meteor 的开发中获得的,但是,我没有在新的 meteor 0.4.0 上验证它。
http://docs.meteor.com/#meteor_startup
Meteor.startup(function () (
$(".screenshot").lightbox();
});
相关文章:
- JQueryhide()不适用于Mozzilla,但适用于Chrome
- PHP中的setcookie仅适用于localhost
- html5 drawImage适用于firefox,而不是chrome
- 提供“;onClick"适用于iPad(触摸屏)和桌面用户的默认功能
- jQuery表单验证适用于Mozilla和Internet Explorer,但不适用于Chrome或Safari
- ResolveUrl是否适用于././也
- Firebase updateChildValues适用于IOS,但不适用于Web和Android
- JavaScript警报适用于int,但不适用于string
- SQLite插件适用于Mac和Windows,但不适用于手机上的Safari
- Regex Replace仅适用于Last Match
- window.onload适用于aspx页面,但不适用于普通html
- Jquery Ajax POST不工作.适用于GET
- 画布上的自定义字体仅适用于safari
- Javascript仅适用于alert()和Debug模式
- JS适用于Firefox和Safari,但不适用于Chrome.此处'是我的网站
- Regex不适用于Firefox,但适用于Chrome
- 通过单击主菜单外部关闭子菜单'不适用于IE,但适用于Firefox&铬
- AngularJS$http.post没有'不适用于Chrome,仅适用于IE
- Javascript仅适用于jQuery mobile中的页面刷新
- JS插件,适用于Meteor