프로젝트는 끝났지만 블로그에 올려야지.. 하고 안올렸던 부분이 있어서 기술하고자 한다
//대댓창 만들기
function Rereply(replylNo,rPage){
if($('#'+replylNo).children('.reReply').length<10){
var str="";
str+='<div class="row mt-2">'
str+='<div class="col-md-11 col-9">'
str+='<textarea name="reRContents'+replylNo+'" id="reply-text" rows="3"></textarea></div>'
str+='<div class="col-md-1 col-3 reply-button-area">'
str+='<button id="reply-button1"token operator">+replylNo+','+rPage+')">답글</button> <button id="reply-button2"token operator">+bookNo+',\''+userId+'\','+rPage+')">취소</button></div></div>'
$('#'+replylNo).append(str)
}else{
alert('대댓글이 10개이상인경우 작성할수 없습니다.')
}
}
//대댓 등록
function reReplyAdd(rNo,rPage){
var rContents = $('[name=reRContents'+rNo+']').val();
$.ajax({
url:"/book/bookReReplyRegist.do",
type:"post",
data:{"reContens":rContents,"replyNo":rNo,"bookNo":bookNo,"category":"origin"},
success:function(){
printReply(bookNo,userId,rPage);
},
error:function(){}
})
}
//대댓글 출력하기
function reReplyAll(rPage,count){
$.ajax({
url:"/book/ReReplyPrint",
type:"post",
data:{"bookNo":bookNo,"category":"origin"},
success:function(result){
for(var i in result){
var str ="";
str ='<div class="row d-flex justify-content-center repleOne reReply mt-2 ps-5" id="rRe'+result[i].reReplyNo+'">';
str+='<div class="card ps-3 pe-3 pt-2 pb-2">';
str+='<div class="d-flex row justify-content-between align-items-center">';
str+='<div class="user col-12 d-flex flex-row align-items-center">';
str+='<span class="col-md-1 col-3 d-inline-block text-truncate">';
str+='<small class="font-weight-bold username">'+result[i].mNickName+'</small>';
str+='</span>';
str+='<span class="col-md-11 col-8">';
str+='<small class="font-weight-bold">';
str+=result[i].reContens;
str+='</small>';
str+='</span>';
str+='</div></div>';
str+='<div class="mt-2">';
str+='<div class="reply row">';
str+='<div class="col-6">';
if(userId==result[i].memberId){
str+='<span class="modify-del-button"> <smalltoken operator">+result[i].reReplyNo+','+rPage+');">삭제</small> <smalltoken operator">+result[i].reReplyNo+','+rPage+');">수정</small>';
}
if(userId!=result[i].memberId && admin=='Y'){
str+='<span class="modify-del-button"> <smalltoken operator">+result[i].reReplyNo+','+rPage+');">삭제</small>';
}
str+='</span></div>';
str+='<div class="text-truncate col-6 date">';
str+='<small>'+result[i].insertDate+'</small>';
str+='</div></div></div>';
$('#'+result[i].replyNo).append(str);
}
totalCount =count+(result.length);
$('#replyLength').html(totalCount);
},
error:function(){}
})
}