Sugar for comment sending.
- Do not send if comment empty - Disable submit button while submit is in progress
This commit is contained in:
parent
22253b4e68
commit
bb37d16dff
@ -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;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user