/** * @file * * * User: marand * Date: 02/09/15 * Time: 08:43 */ Template.postEdit.events({ 'submit form': function (e) { e.preventDefault(); var currentPostId = this._id; var postProperties = { url: $(e.target).find('[name=url]').val(), title: $(e.target).find('[name=title]').val() }; Posts.update(currentPostId, { $set: postProperties },function (error, result) { // Display the error to the user and abort. if (error) { return alert(error.reason); } else { Router.go('postPage', { _id: currentPostId }); } }); }, 'click .delete': function (e) { e.preventDefault(); if (confirm("Delete this post ?")) { var currentPostId = this._id; Posts.remove(currentPostId); Router.go('postsList'); } } });