简体   繁体   中英

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.

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..

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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