开发者

Using an ID to Reply to a Comment with jQuery in a Spring-MVC app

I need to be able to comment to an article, but also be able to reply to a comment using the same form. Fairly simple, but how do I know that a user clicked on "REPLY", and know which comment they clicked "REPLY" too? I'd imaging I need to add some attribute to the anchor, but I'm not sure what it should be. I'd like this to be a best practice kind of thing.

you have Spring-mvc, JSP, and jQuery at your disposal

these anchors are generated at the bottom of every comment, you have access to any comment info you need from the model at this point: <a href="#" title="Reply"><img src="<spring:url value="/static/images/reply.png"/>" alt="reply" width="10" height="10" border="0" />REPLY</a>

this is the actual form to make a comment:

&l开发者_高级运维t;form:form action="comment.do" method="PUT">
    <div class="aclass">
        <h2>post a comment</h2>
    </div>
    <input type="hidden" name="replyto" value=""/>
    <input type="text" class="commentArea" name="comment"/>
    <div style="margin: 5px 0 0 0">
        <input type="submit" value="Submit Comment" title="Submit Comment" />
        &nbsp;
    </div>
</form:form>

brownie points for making clicking "reply" scroll the user to the comment form :)


Store the ID of the comments in each reply button, so when it is clicked you can move that ID to a hidden form field for your comment box. If no ID is present then it is a normal comment and not a reply.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜