I insert element from the php file as a result of successful ajax call. But for some reason that and everything in it is missing when I look at my source code of the page. It appears on the page correctly but it isn't clickable or anything until I refresh my page! How can I make elements usable right after successful AJAX call?
Jquery AJAX:
$( "#addvideo" ).click(function() {
$.ajax({
type: "POST",
datatype: 'json',
url: "/public/index.php/admin/content/athletes/addvideo",
data: { youtube: $("input[name=youtube]").val(), vid:$("input[name=athletes_vid]").val(), ci_csrf_token: $("input[name=ci_csrf_token]").val() }
})
.done(function( data ) {
$('#youtubeholder').last().append(data);
});
});
This call appends following data
from php controller:
$jquery_data = "<div style='float: left; width: 200px; height: 200px' id='video_pic'>
<img id='".$id."' src='".img_path().$tb_data->filename."' /><br/>
<div class='btn deletevid' style='width: 145px; margin-left: auto; margin-right: auto;'>DELETE</div>
</div>";
echo $jquery_data;
To the <div id="youtubeholder">
on the same page as AJAX call. However nothign happens when I click the "DELETE" button.