diff options
author | Matt Claypotch <thepotch@gmail.com> | 2010-08-24 01:25:40 (GMT) |
---|---|---|
committer | Matt Claypotch <thepotch@gmail.com> | 2010-08-24 01:25:40 (GMT) |
commit | 819a52b38386b7f024236e91dc440d2072e96730 (patch) | |
tree | a2397f5df7c5c5acb6047fed5f5dfff86c38ae5d /media | |
parent | f72883760b5cb8acb934fa4426ead7df5339039f (diff) |
Inline edit tweaks
Diffstat (limited to 'media')
-rw-r--r-- | media/js/zamboni/reviews.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/media/js/zamboni/reviews.js b/media/js/zamboni/reviews.js index d56ae53..c182ac4 100644 --- a/media/js/zamboni/reviews.js +++ b/media/js/zamboni/reviews.js @@ -50,6 +50,7 @@ $(document).ready(function() { $review = $(this).parents(".review"), rating = $review.attr("data-rating"), edit_url = $("a.permalink", $review).attr("href") + "edit"; + $cancel = $("#review-edit-cancel"); $review.attr("action", edit_url); $form.detach().insertAfter($review); @@ -59,11 +60,15 @@ $(document).ready(function() { $review.hide(); $form.show(); - $("#review-edit-cancel").click(function(e) { - e.preventDefault(); - $form.hide(); + function done_edit() { + $form.unbind().hide(); $review.show(); - $(this).die(); + $cancel.unbind(); + } + + $cancel.click(function(e) { + e.preventDefault(); + done_edit(); }); $form.submit(function (e) { @@ -77,9 +82,7 @@ $(document).ready(function() { $(".stars", $review).removeClass('stars-0 stars-1 stars-2 stars-3 stars-4 stars-5').addClass('stars-' + rating); rating = $review.attr("data-rating", rating); $review.children("p.review-body").text($("#id_body").val()); - $review.show(); - $form.hide(); - $('#review-edit-cancel').die(); + done_edit(); }, dataType: 'json' }); |