Update Dom With Result from Ajax with Action Event Not Working

I’m Developing a Comment Replay System As any Social Media website But Using YII2 Framework
I Created Wedget To Show a list of Comments On Some Items ( like products )
Each Comment is With button “Replay” to allow user to send replay for this comment
Or Add new comment to The Item (product).
Using Ajax.post i do the post and retrive the new inserted Comment.
My Poroblem is:

When i Post the request and get the result
How To Append This result ( Best Way) So THAT IF THE BUTTON OF NEWLY INSERTED COMMENT PRESSED WILL FIRE

This Will Send the post and get result..

“ $.ajax({
url: ‘$url’,
type: ‘POST’,
data: formData,
success: function (result) {
if(result.success === 1){
//alert(result.msg);
var new_comment =result.data;
$(new_comment).appendTo(‘#comment_’+id+’container’);
//$(‘#comment
‘+id+’container’).append(new_comment);
$(bdySelector).val(”);
$(‘.hideme
‘ + id).toggleClass(‘d-none’);
return false;
}else
$(bdySelector).val(”);

        $('#errors'+id).removeClass('d-none').innerText(result.errors);
        return true;
}``

this code shoul work for new inserted comment but its not
$(document).on('click', '.ShowDialog', function(e){ var id = document.getElementById(e.target.id).getAttribute('data-comment-id'); $('.hideme_' + id).toggleClass('d-none'); });


in short : I need to append some HTML RESULT into Continer
but this inserted HTML Result is not responding to my click event on it’s own buttons

i have tried this but not working
` $.ajax({
url: ‘$url’,
type: ‘POST’,
data: formData,
success: function (result) {
if(result.success === 1){
//alert(result.msg);
var new_comment =result.data;
$(new_comment).appendTo(‘#comment_’+id+’container’);
//$(‘#comment
‘+id+’container’).append(new_comment);
$(bdySelector).val(”);
$(‘.hideme
‘ + id).toggleClass(‘d-none’);
return false;
}else
$(bdySelector).val(”);

        $('#errors'+id).removeClass('d-none').innerText(result.errors);
        return true;
}`