Need help appending link with generated values

Need help appending link with generated values

First, some background: I'm trying to create links for replying to replies in a Movable Type-powered forum. I'm going for a similar effect to Digg's comments, where after two replies, they become flat.

To do this, I need to get the ID of the parent comment. You can see below that I'm able to get it, and it gives me the right value when I alert it. The problem is getting that ID into the onclick for the "reply to thread" link.

Each page will have multiple instances of this, so I need to take that into account.There's comments in my code below to make it a little more clear.

I realize this is going to make a pretty ugly looking link, but I'm just emulating the way Movable Type's javascript does it for normal reply links.

Thanks!

  1. $(document).ready(function(){
  2. $('.sub .reply-link').append('<a href="javascript:void(0);"' + '" onclick="mtReplyCommentOnClick(' + '2633' + ',' + '\'user name\')">Reply to thread</a>'); // 2633 is a dummy value. I need to replace it with the real value
  3. $('.reply-link a').click(function(){ // This is just in the click event for testing because I'm not sure how to do it when the page loads.
  4. var parentCommentId = $(this).parents('div.comment').attr("id");  // Get the ID of the div containing the parent comment
  5. var replyToId = parentCommentId.replace(/comment-/, '') // This gives me the same value as the MT Comment ID
  6. alert(replyToId); // The alert is just to make sure I'm getting the ID
  7. });
  8. });