728x90
팀원에게 여태까지 한 페이지 기능들을 보여주다가 꺠달은게 있다.
댓글 작성자와 그렇지 않은 사람으로 구분했었는데 게시글 작성자와도 구분을 했어야 했다.
게시글 작성자 o 댓글 작성자 x
게시글 작성자 o 댓글 작성자 o
게시글 작성자 x 댓글 작성자 x
게시글 작성자 x 댓글 작성자 o
게시글 작성자 인 경우
댓글 작성자가 아닌 경우
댓글 작성자인 경우
댓글 작성자가 아닌 경우
댓글 작성자가 아닌 경우
댓글 작성자인 경우
if (writerRegistry == commentName) { // 게시글 작성자인 경우
// 댓글 작성자인 경우
// 댓글 작성자가 아닌 경우
}
else{ // 댓글 작성자가 아닌 경우
// 댓글 작성자인 경우
// 댓글 작성자가 아닌 경우
}
기존 코드는 댓글 작성자와 아닌 경우만 분리했다.
temp_html= `<div id="commentParent" class="${commentId}" style="display:block;"><a id="${commentId}-commentName" class="commentName">${commentName} </a><a id="${commentId}-comment">${comment}</a></div> <br><input id="updateCommentBtn" style="display: none">`
if (nickname == commentName) { // 댓글 작성자인 경우
temp_html = `<div id="commentParent" class="${commentId}" ><a id="${commentId}-commentName" class="writerCommentName">${commentName} </a><a id="${commentId}-comment">${comment}</a>
<button id="updateBtn-${commentId}" class="updateBtn" type="button" onclick="updateCommentBtn(${commentId})">수정</button>
<button id="deleteBtn-${commentId}" class="deleteBtn" type="button" onclick="checkDelete(${commentId})">삭제</button></div>
<a><input id="updateCommentInput-${commentId}" class="updateCommentInput" style="display: none"><button id="updateAftersaveBtn-${commentId}" class="updateAftersaveBtn" style="display: none" type="button" onclick="afterUpdateComment(${commentId})">저장</button> </a><br>`
}
$("#commentList").append(temp_html)
728x90
'TIL' 카테고리의 다른 글
288일차(모험 197일차) - test 코드 (0) | 2022.06.30 |
---|---|
287일차(모험 196일차) - 작성자 값을 가져오지 못하는 현상 (0) | 2022.06.29 |
285일차(모험 194일차) - id값 변경, test 코드 (0) | 2022.06.27 |
282일차(모험 191일차) - css, js 수정 (0) | 2022.06.24 |
281일차(모험 190일차) - 닉네임 받아오기 (0) | 2022.06.23 |