Skip to content

Commit d98cc17

Browse files
committed
댓글 삭제 기능 추가
1 parent ac31025 commit d98cc17

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

routes/admin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ router.get('/',function(req,res){
1010

1111
//admin/이후의 url을 적는다
1212
//res.send("admin products");
13+
//products list 페이지
1314
router.get('/products', function (req, res) {
1415
ProductsModel.find(function(err, products){//인자는 에러와 products
1516
res.render('admin/products',//views의 위치
@@ -30,7 +31,6 @@ router.post('/products/write', function (req, res) {
3031
description: req.body.description,
3132
});
3233
//유효성체크 후 DB로 넘길지 말지 결정
33-
3434
if (!product.validateSync()) {
3535
product.save(function (err) {
3636
res.redirect('/admin/products');

views/admin/productsDetail.ejs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
<hr />
2121
<div id="comment_area">
2222
<% comments.forEach( function(comment){ %>
23-
<div>
24-
<%=comment.content%>
25-
[<a class='comment_delete' comment_id='<%=comment.id%>'>삭제</a>]
26-
</div>
27-
<%});%>
23+
<div><%#이 태그가 remove된다.%>
24+
<%=comment.content%>
25+
[<a class='comment_delete' comment_id='<%=comment.id%>'>삭제</a>]
26+
</div>
27+
<% }); %>
2828
</div>
2929

3030

@@ -69,7 +69,7 @@
6969
);
7070
$('#commentForm textarea[name=content]').val("");
7171
}
72-
//console.log(args);//message 하나만 출력
72+
//console.log(args.message);//message 하나만 출력
7373
})
7474
.fail(function(args){
7575
console.log(args);
@@ -82,13 +82,13 @@
8282
});
8383
8484
$(document).on('click','.comment_delete',function(){
85-
if(confirm('삭제하시겠습니까?')){
86-
var $self =$(this); //여기서 this는 해당 댓글의 <a>태그를 뜻함
85+
if(confirm('삭제하시겠습니까?')){//확인창에 눌렀을 시만 진행
86+
var $self = $(this); //여기서 this는 해당 댓글의 <a>태그를 뜻함
8787
$.ajax({
8888
url: '/admin/products/ajax_comment/delete',
8989
type: 'POST',
9090
data: {comment_id : $self.attr('comment_id')},//변수의 attribute로 접근
91-
});
91+
})
9292
.done(function(){
9393
$self.parent().remove();//<a>태그의 parent니까 <div>
9494
alert("삭제가 완료되었습니다.");

0 commit comments

Comments
 (0)