12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- /**
- * Template helpers.
- */
- // helper function that returns all available websites
- Template.website_list.helpers({
- websites: () => {
- return Websites.find({});
- }
- });
- /**
- * Template events
- */
- Template.website_item.events({
- "click .js-upvote": function (event) {
- // Example of how you can access the id for the website in the database
- // (this is the data context for the template)
- const websiteId = this._id;
- console.log("Up voting website with id " + websiteId);
- // Put the code in here to add a vote to a website!
- // Prevent the button from reloading the page.
- return false;
- },
- "click .js-downvote": function (event) {
- // example of how you can access the id for the website in the database
- // (this is the data context for the template)
- const websiteId = this._id;
- console.log("Down voting website with id " + websiteId);
- // Put the code in here to remove a vote from a website!
- // Prevent the button from reloading the page
- return false;
- }
- });
- Template.website_form.events({
- "click .js-toggle-website-form": function () {
- $("#website_form").toggle("slow");
- },
- "submit .js-save-website-form": function (event) {
- // here is an example of how to get the url out of the form:
- const url = event.target.url.value;
- console.log("The url they entered is: " + url);
- // put your website saving code in here!
- // Stop the form submit from reloading the page
- return false;
- }
- });
|