Support » Plugin: Easy FancyBox » Using inline code within Javascript

  • Hi

    I’m trying to use your inline code within some Javascript to add a popup window to dynamic content pulled in via an API. Apologies if that’s not the right terminology but I’m more designer than developer!

    Here’s the code and there’s a link to the page as well. You can also see some text at the top of the page ‘Popup Test’ which is working fine in plain html, it’s just the 10 or so large promotion images which are pulled in through the Javascript which should have popups on which aren’t working

    function promotionHtml(promotion) {
    	var html = '';
    	html += '<div class="single-promotion">';
    	html += '<a class="fancybox-inline" href="#' +promotion.id+ '"><img src="' +promotion.bigImageUrl+ '"></a>';
    	html += '<div class="fancybox-hidden" style="display: none;">';
    	html += '<div id="' +promotion.id+ '">';
    	html += '<h3>' +promotion.title+ '</h3>';
    	html += '<p>' +promotion.subTitle+ '</p>';
    	html += '<p>' +promotion.htmlSummary+ '</p>';
    	html += '</div>' + '</div>' + '</div>';
    	return html;
    }

    Any help would be gratefully received!

    Many thanks

    David

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author RavanH

    (@ravanh)

    Hi David, your terminology is clear I think I understand what you are trying to do 🙂

    Code that has been added/updated through javascript is not seen by the Fancybox script because it scans the source only on document load for media links. But there is a way to make the script scan the source again:

    
    jQuery(document.body).trigger('post-load');
    

    This event should be called after new content has been loaded. Normally that would be at the end of the “succes” method of an Ajax call but in your case you could try adding it at the end of the $(document).ready(function(){...} (inside that function at the end, but not after!) in the progressplay.js script.

    That’s brilliant, many thanks for the quick response – all working now!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using inline code within Javascript’ is closed to new replies.