/** * Client code for the website_form template. * * - events */ Template.website_form.events({ "click .js-toggle-website-form": function () { $("#website_form").toggle("fast"); }, "click #site-lookup": function (event) { event.preventDefault(); const url = $(event.target).parent().prev().val(); Meteor.call("loadSite", url, function (error, result) { let $result = $("" + result + ""); let titleElement = $($result.find("title")[0]).text(); let metaTitle = $result.find("meta[name=\"title\"]").attr("content"); let metaDescription = $result.find("meta[name=\"description\"]").attr("content"); let title = [titleElement, metaTitle].join(" / "); $("#title").val(title); $("#description").val(metaDescription); }); }, "submit .js-save-website-form": function (event) { event.preventDefault(); // here is an example of how to get the url out of the form: const url = event.target.url.value; const title = event.target.title.value; const description = event.target.description.value; let poster = { _id: Meteor.userId(), name: Meteor.user().username }; const postDate = new Date(); // put your website saving code in here! const doc = { url, title, description, poster, postDate }; doc.words = toWords(doc); Meteor._debug("Client trying to insert", doc); Websites.insert(doc); } });