/** * @file * * * User: marand * Date: 31/08/15 * Time: 20:47 */ Template.postSubmit.events({ 'submit form': function (e) { e.preventDefault(); var post = { url: $(e.target).find('[name=url]').val(), title: $(e.target).find('[name=title]').val() }; Meteor.call('postInsert', post, function (error, result) { // Display the error to the user and abort. if (error) { return alert(error); } if (result.postExists) { alert("This link has already been posted"); } // Router.go('postPage', { _id: result._id }); }); // Return to list page without waiting for the insert. Router.go('postsList'); } });