关于做系统的评论添加功能

  上面是一些框框,当用户把他想要发表的东西给输入进去后,点发表,通过dwr等一些手段把数据给存入数据库中,然后通过 dwr异步地把信息给查出来再显示。我目前就这么做的。

 

$(function(){   

getCommentByItemId();

})

 

function getCommentByItemId(){

        commentService.getCommentByItemId($articleId, {

            callback : function(data) {

   var commentList = $("#commentList");

commentList.html("");

for(var index in data){

var bean = data[index];

var appendValue = "";

appendValue += "<div class='LY_content_rightC_list'>";

appendValue += "<p class='title'><span class='title_right'>";

appendValue += (bean.createTime.getYear()+1900)+"年"+(bean.createTime.getMonth()+1)+"月"+bean.createTime.getDate()+"日  "+

bean.createTime.getHours()+":"+bean.createTime.getMinutes();

appendValue += "发表 </span><span class='title_left'>";

appendValue += bean.userName;

appendValue += "</span></p>";

appendValue += "<p class='content'>";

appendValue += bean.content;

appendValue += "</p><p class='func'><a href='#' οnclick='updateSupport(";

appendValue += bean.commentId;

appendValue += ")'>支持</a>[<span id='support";

appendValue += bean.commentId;

appendValue += "'>";

appendValue += bean.support;

appendValue += "</span>]&nbsp;&nbsp;";

appendValue += "<a href='#' οnclick='updateOppose(";

appendValue += bean.commentId;

appendValue += ")'>反对</a>[<span id='oppose";

appendValue += bean.commentId;

appendValue += "'>";

appendValue += bean.oppose;

appendValue += "</span>]</p></div>";

commentList.append(appendValue);

}

            }

        });

}

 

 

function updateSupport(commentId){

        commentService.updateSupport(commentId, {

            callback : function(data) {

             if(data == 'success'){

var value = parseInt($("#support"+commentId).text()) + 1;

$("#support"+commentId).text(value);

}

else if(data == 'have'){

}

else{

alert('支持失败');

}

            }

        });

}

 

function updateOppose(commentId){

        commentService.updateOppose(commentId, {

            callback : function(data) {

             if(data == 'success'){

var value = parseInt($("#oppose"+commentId).text()) + 1;

$("#oppose"+commentId).text(value);

}

else if(data == 'have'){

}

else{

alert('反对失败');

}

            }

        });

}

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值