#200 fixes for postComment
This commit is contained in:
parent
c1ae259562
commit
476761986d
@ -164,13 +164,28 @@
|
||||
window.open(macagna, '_blank', 'width=600,height=700,scrollbars=yes,status=yes');
|
||||
}
|
||||
|
||||
function postComment(parent, commentformSelector, commentErrorSelector) {
|
||||
function postComment(coupletIndex) {
|
||||
var commentformSelector = '#commentform';
|
||||
if (coupletIndex != '') {
|
||||
commentformSelector += ('-' + coupletIndex);
|
||||
}
|
||||
$(commentformSelector).unbind('submit').bind('submit', function (e) {
|
||||
|
||||
e.preventDefault(); // avoid to execute the actual submit of the form.
|
||||
|
||||
var commentErrorSelector = '#comment-error';
|
||||
if (coupletIndex != '') {
|
||||
commentErrorSelector += ('-' + coupletIndex);
|
||||
}
|
||||
|
||||
$(commentErrorSelector).remove();
|
||||
|
||||
var parent1 = $('#comments-block');
|
||||
var parent2 = null;
|
||||
if (coupletIndex != '') {
|
||||
parent2 = $('#comments-block-'+coupletIndex);
|
||||
}
|
||||
|
||||
var form = $(this);
|
||||
var url = form.attr('action');
|
||||
|
||||
@ -179,14 +194,17 @@
|
||||
url: url,
|
||||
data: form.serialize(), // serializes the form's elements.
|
||||
success: function (data) {
|
||||
$(data).appendTo(parent);
|
||||
$('#comment-error')[0].reset();
|
||||
$(data).appendTo(parent1);
|
||||
if (parent2 != null)
|
||||
$(data).appendTo(parent2);
|
||||
$(commentErrorSelector)[0].reset();
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function replyComment(commentId, loggedIn, divSuffix) {
|
||||
if (!loggedIn) {
|
||||
alert('برای پاسخگویی لازم است با نام کاربری خود وارد گنجور شوید.');
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button name="postcomment" class="inputSubmit" onclick="return postComment(document.getElementById('comments-block-@Model.CoupletIndex'), '#commentform-@Model.CoupletIndex', '#comment-error-@Model.CoupletIndex');" style="width:100%">درج حاشیه</button>
|
||||
<button name="postcomment" class="inputSubmit" onclick="return postComment('@Model.CoupletIndex');" style="width:100%">درج حاشیه</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -420,7 +420,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button name="postcomment" id="postcomment" class="inputSubmit" onclick="return postComment(document.getElementById('comments-block'), '#commentform', '#comment-error');" style="width:100%">درج حاشیه</button>
|
||||
<button name="postcomment" id="postcomment" class="inputSubmit" onclick="return postComment('');" style="width:100%">درج حاشیه</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user