我正在尝试在meteor.js 应用程序中使用像这样的jquery。
JS:
if (Meteor.isClient) {
Meteor.startup(function() {
$( "button" ).click(function() {
$( "p" ).toggle();
});
});
...
或者没有meteor.startup功能。两者都不起作用。
HTML:
<button>Click</button>
<p>Can you see me?</p>
当我单击按钮时,我没有收到任何错误,也没有任何反应。
您不应该使用 jQuery 进行像这样的简单事件处理,而是使用 Meteor 模板事件映射:
HTML :
<template name="myTemplate">
<button type="button">Click me !</button>
<p>Can you see me ?</p>
</template>
JS :
Template.myTemplate.events({
"click button":function(event, template){
template.$("p").toggle();
}
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)