I am dynamically loading content (Via Ajax) into a <div>
called <div id="displayinformation">
Some of the content is formatted in a way that if there is a link, a Fancybox lightbox is to appear.
I have tested the Fancybox and it works if the content does not load from Ajax. But loaded from Ajax, it does nothing.
I believe that it perhaps has something to do with: $(document).ready(function() {
though I am not sure.
I think I need to run the code for the lightbox once the ajax content has been loaded.
My code is below, would be grateful for any insights. Kind regards, Paul.
Call in:
<a href="http://player.vimeo.com/video/61692184" title="Lower Title Text" rel="displayvideo" >XX</a>
Top JS:
<script type="text/javascript">
$(document).ready(function() {
$("a[rel=displayvideo]").fancybox({
'overlayShow' : true,
'width' : 800,
'height' : 450,
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'titlePosition' : 'inside',
'type' : 'iframe',
'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
return '<span id="fancybox-title-inside">Video:' + (title.length ? ' ' + title : '') + '</span>';
}
});
</script>