Sugar for comment sending.

- Do not send if comment empty
    - Disable submit button while submit is in progress
This commit is contained in:
Antonin 2015-10-28 16:36:54 +01:00
parent f6f04c69e0
commit 1ec9ea2dd5

View File

@ -49,6 +49,8 @@ $(document).ready(function () {
form.submit(function(event) { form.submit(function(event) {
event.preventDefault(); event.preventDefault();
if ($('#comment').val()) {
$('#add_comment').attr("disabled", "disabled");
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: form.attr('action'), url: form.attr('action'),
@ -57,7 +59,6 @@ $(document).ready(function () {
success: function(data) success: function(data)
{ {
$('#comment').val(''); $('#comment').val('');
if (data.result) { if (data.result) {
$('#comments_list') $('#comments_list')
.replaceWith(data.comments); .replaceWith(data.comments);
@ -81,8 +82,12 @@ $(document).ready(function () {
scrollTop: commentsAlert.offset().top scrollTop: commentsAlert.offset().top
}, 750); }, 750);
} }
},
complete: function() {
$('#add_comment').removeAttr("disabled");
} }
}); });
}
return false; return false;
}); });