I think this may be a simple question, hopefully it's just my poor syntax understanding.
I'm attaching event handlers to some links
inside comment boxes like so:
Code:
$(".comments_previous, .comments_next").click(function(){
var oCommentDiv = $(this).parent().parent();
iCommentId = 1;
sDirection = 'prev';
$.get("ajax_getcomment.asp", { commentid: iCommentId, direction: sDirection },function(data){
oCommentDiv.html(data);
});
// reattach event handlers to newly-generated links.
//$(".comments_previous, .comments_next").click();
return false;
});
So. Someone clicks a link inside a div, and the content of that div is updated with the results of an AJAX call. That bit currently works fine.
The HTML that is passed back in that AJAX call also contains some links. And I want exactly the same thing to happen when
they're clicked: AJAX is fired, container div is updated.
But I don't know how to attach the event handlers to those links that have just been added. I know I need to call the event-attaching bit again - as shown in the highlighted code above - but I don't know what I should be passing as the function arguments.
Can anyone enlighten me?