简体   繁体   English

与Meteor.js的jQuery [Template.name.rendered]

[英]jQuery with Meteor.js [Template.name.rendered]

i've read that when you have Template.name.rendered = function(){ ... } You can use regular jQuery code in it. 我已经读过当你有Template.name.rendered = function(){...}时你可以使用常规的jQuery代码。

I am trying to make it possible to when a user post a comment, the post either slides down or pops up depending on what i put in the jQuery code.. 我试图让用户发表评论时,该帖子可以向下滑动或弹出,具体取决于我在jQuery代码中添加的内容。

Here is what i have so far 这是我到目前为止所拥有的

 Template.posts.rendered = function(){ if (!this.rendered){ function setEvents(){ $(".posts").on("click", function(){ $(this).slideDown(750); }); }; var init = function(){ setEvents(); }(); this.rendered = true; } }; 

The Meteoric way of doing this is using Template events 这样做的Meteoric方法是使用Template 事件

Template.posts.events({
  'click': function(){
    $(".posts").slideDown(750);
  }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM