I'm using FitVids.js to dynamically resize my videos. I also have a little script to make it so I can click an image and the image is replace with a YouTube video. However these videos aren't getting the fitvids script applied to them.
Here is the video and replacement script
<img id="homevideo" src="image.jpg"
data-video="http://www.youtube.com/embed/[URL-key]?autoplay=1">
<script>
jQuery(document).on('click','#homevideo',function(e){
var video = '<iframe id="feature_video" src="'+jQuery(this).attr('data-video') +'" width="400" height="300"></iframe>';
jQuery(this).replaceWith(video);
});
</script>
This is the script I need applied to the element when it is created
jQuery("#feature_video").fitVids();