website_form.js 841 B

12345678910111213141516171819202122232425262728293031
  1. /**
  2. * Client code for the website_form template.
  3. *
  4. * - events
  5. */
  6. Template.website_form.events({
  7. "click .js-toggle-website-form": function () {
  8. $("#website_form").toggle("slow");
  9. },
  10. "submit .js-save-website-form": function (event) {
  11. // here is an example of how to get the url out of the form:
  12. const url = event.target.url.value;
  13. const title = event.target.title.value;
  14. const description = event.target.description.value;
  15. let poster = {
  16. _id: Meteor.userId(),
  17. name: Meteor.user().username
  18. };
  19. const postDate = new Date();
  20. // put your website saving code in here!
  21. const doc = { url, title, description, poster, postDate };
  22. Meteor._debug("Client trying to insert", doc);
  23. Websites.insert(doc);
  24. // Stop the form submit from reloading the page
  25. return false;
  26. }
  27. });