#200 having comment post button text being changed and disabled while posting a new comment

This commit is contained in:
Hamid Reza Mohammadi 2021-09-09 16:29:28 +04:30
parent 288cf550f0
commit 68b1d620eb
3 changed files with 14 additions and 5 deletions

View File

@ -164,7 +164,7 @@
window.open(macagna, '_blank', 'width=600,height=700,scrollbars=yes,status=yes');
}
function postComment(coupletIndex) {
function postComment(coupletIndex, buttonSelector) {
var commentformSelector = '#commentform';
if (coupletIndex != '') {
commentformSelector += ('-' + coupletIndex);
@ -173,6 +173,9 @@
e.preventDefault(); // avoid to execute the actual submit of the form.
$(buttonSelector).text('در حال درج حاشیه ...');
$(buttonSelector).prop("disabled", true);
var commentErrorSelector = '#comment-error';
if (coupletIndex != '') {
commentErrorSelector += ('-' + coupletIndex);
@ -183,7 +186,7 @@
var parent1 = $('#comments-block');
var parent2 = null;
if (coupletIndex != '') {
parent2 = $('#comments-block-'+coupletIndex);
parent2 = $('#comments-block-' + coupletIndex);
}
var form = $(this);
@ -193,11 +196,17 @@
type: "POST",
url: url,
data: form.serialize(), // serializes the form's elements.
error: function () {
$(buttonSelector).text('درج حاشیه');
$(buttonSelector).prop("disabled", false);
},
success: function (data) {
$(data).appendTo(parent1);
if (parent2 != null)
$(data).appendTo(parent2);
$(commentErrorSelector)[0].reset();
$(buttonSelector).text('درج حاشیه');
$(buttonSelector).prop("disabled", false);
form[0].reset();
},
});

View File

@ -38,7 +38,7 @@
</tr>
<tr>
<td>
<button name="postcomment" class="inputSubmit" onclick="return postComment('@Model.CoupletIndex');" style="width:100%">درج حاشیه</button>
<button name="postcomment-@Model.CoupletIndex" id="postcomment-@Model.CoupletIndex" class="inputSubmit" onclick="return postComment('@Model.CoupletIndex', '#postcomment-@Model.CoupletIndex');" style="width:100%">درج حاشیه</button>
</td>
</tr>
</table>

View File

@ -420,7 +420,7 @@
</tr>
<tr>
<td>
<button name="postcomment" id="postcomment" class="inputSubmit" onclick="return postComment('');" style="width:100%">درج حاشیه</button>
<button name="postcomment" id="postcomment" class="inputSubmit" onclick="return postComment('', '#postcomment');" style="width:100%">درج حاشیه</button>
</td>
</tr>
</table>