fixed! :: Lightbox doesn't work when you load page with AJAX
-
Ok So I was talking to the plugin developer about my challenge in getting the lightbox to work when i loaded the plugin’s widget with an AJAX. I did so because I am trying to improve seo by cutting down the page size and loading the heavy files at client side.
The only problem was that when you click on a video thumbnail, instead of playing in the lightbox (ie if you have made that an option), it will rather open the youtube url in the same window.
I realized i had to reinitialize the part handling the lightbox. To help anyone who will be in similar need, and save our great guy sometime here, i am posting the solution.I first create a ytc function to handle the magnificPOpupAU script that handles the lightbox and put it above the jQuery(document).ready(function($)
SO put this above that;
function ytc_lightbox () {
jQuery(‘.ytc-lightbox’).magnificPopupAU({
disableOn:320,
type:’iframe’,
mainClass:’ytc-mfp-lightbox’,
removalDelay:160,
preloader:false,
fixedContentPos:false
});
}and within your ajax
function( response ) {// success
after ajax render the HTML
Reinitialise the part of the plugin you need, ie the script we created above. so in this example:
ytc_lightbox();
And viola!!!!
Thanks a lot URKEKG, you are a big savior!
I hope this helps someone out.
- The topic ‘fixed! :: Lightbox doesn't work when you load page with AJAX’ is closed to new replies.