client.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Template helpers.
  3. */
  4. // helper function that returns all available websites
  5. Template.website_list.helpers({
  6. websites: () => {
  7. return Websites.find({});
  8. }
  9. });
  10. /**
  11. * Template events
  12. */
  13. Template.website_item.events({
  14. "click .js-upvote": function (event) {
  15. // Example of how you can access the id for the website in the database
  16. // (this is the data context for the template)
  17. const websiteId = this._id;
  18. console.log("Up voting website with id " + websiteId);
  19. // Put the code in here to add a vote to a website!
  20. // Prevent the button from reloading the page.
  21. return false;
  22. },
  23. "click .js-downvote": function (event) {
  24. // example of how you can access the id for the website in the database
  25. // (this is the data context for the template)
  26. const websiteId = this._id;
  27. console.log("Down voting website with id " + websiteId);
  28. // Put the code in here to remove a vote from a website!
  29. // Prevent the button from reloading the page
  30. return false;
  31. }
  32. });
  33. Template.website_form.events({
  34. "click .js-toggle-website-form": function () {
  35. $("#website_form").toggle("slow");
  36. },
  37. "submit .js-save-website-form": function (event) {
  38. // here is an example of how to get the url out of the form:
  39. const url = event.target.url.value;
  40. console.log("The url they entered is: " + url);
  41. // put your website saving code in here!
  42. // Stop the form submit from reloading the page
  43. return false;
  44. }
  45. });