{#template /layout.html} {#def breadcrumbs} Blog / {=article/title} {/#def} {#def content} {:s article} {#include /articles/article.inc.html} {/:s}

{=/article/commentCount} Comments

{:r comments} {#include /comments/comment.inc.html} {/:r}

{/#def} {#def script} $(".article .DELETE").live("click", function (e) { e.preventDefault(); if (confirm("Are you sure?")) { $.post(e.target.href, { _method: "DELETE" }, function () { window.location.href = "/"; }); $("body").fadeOut(); } }); $(".comment .DELETE").live("click", function (e) { e.preventDefault(); if (confirm("Are you sure?")) { $("#comments>h2").html((parseInt($("#comments>h2").html().split(" "), 10) - 1) + " Comments"); $(e.target).parent().parent().fadeOut(); $.post(e.target.href, { _method: "DELETE" }); } }); var form = $("#commentform"); form.bind("submit", function (e) { e.preventDefault(); e.stopPropagation(); var f = e.target, errors = {}, params = { article: f.article.value, author: f.author.value, email: f.email.value, uri: f.uri.value, content: f.content.value }; if (!params.author) errors.author = "Please provide an author name"; if (!params.email) errors.email = "Please provide an email"; if (!params.content) errors.content = "Please provide the content"; for (var i in errors) { showErrors(form, errors); return false; } $.post("/comments", params, function (res) { if (res.errors) { $("#waiting").remove(); showErrors(form, res.errors); return false; } else { $("#waiting").remove(); $("#comments").append(res.html); f.content.value = ""; $("#comments>h2").html((parseInt($("#comments>h2").html().split(" "), 10) + 1) + " Comments"); } }); form.find("fieldset.submit").append(''); }); {/#def}