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 22253b4e68
commit bb37d16dff

View File

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