So I am having some troubling results with jQuery ".on" function and a dynamically created element, the code I am using is this:
this is called in a function sometime random during runtime:
$(".activity-feed").append('<div class="feed-story big-feed-story feed-story-comment multiline-feed-story">\
<div class="photo-view inbox-size photo-view-rounded-corners">\
<div class="comment-icon">\
</div>\
</div>\
<div class="comment-content">\
<div class="delete ucomment-delete click-target" id="ucomment-'+uqid+'" tabindex="-1" style="outline:none;"></div>\
<span class="feed-story-creator"><a href="/user/'+uid+'/'+username+'">'+username+'</a> </span>\
<span class="comment-text">\
<span>\
<span style="white-space: pre-wrap;">'+$(".comment-box").html()+'</span>\
</span>\
</span>\
<div>\
<span class="feed-story-footer"><span class="story-timestamp-view">'+time+'</span></span>\
</div>\
</div>\
</div>');
and then this function should allow for comment deletion (its defined at the bottom of the page, not after document ready)
$(".delete").on("click", function() {
alert('test....');
});
however, I click on the "ucomment-delete" button, and nothing happens :(, however if I click the comments that were there on load, it works
Why is this? What am I doing wrong?