I wanted to have the pictures on my "sidebar" (the pictures are on the header) load dynamically every certain time so I made an ajax javascript that re-loads the images every 5 minutes, the script just calls a .php page with this on it:
<?php require($_SERVER['DOCUMENT_ROOT'].'/blog/wp-blog-header.php'); ?>
<?php print g2_sidebargridblock('randomImage', 5, 150, ''); ?>
Everything works fine except lightbox. It works just fine the first time I load the page, but when the images reload and I click them it redirects me to the image url instead of opening lightbox. I tried to hack the code but I just don’t know where to look to fix this, has anyone tried something like this?
You can see the page here.
http://thedarksoul.org/blog/
Click on “reload header pictures” to test it.
Any help will be much appreciated!
Posts: 2
Ok, if anyone cares, I was able to fix the problem.
Under much thinking and consideration I tracked down the issue to lightbox, then did a google search and found this:
http://www.dynamicdrive.com/forums/showthread.php?t=25671&highlight=lightbox+ajax
Then searched for this string “lightbox[wpg2grid]” in wpg2embed.inc which took me to this line:
$img = str_replace('><img', ' rel="lightbox[wpg2grid]"><img', $img);
And changed it for this:
$img = str_replace('><img', ' onclick="myLightbox.start(this); return false;" rel="lightbox[wpg2grid]"><img', $img);
And problem solved
Posts: 1378
Interesting issue, Ajax and JS should play well together. We are moving away from the big bulky lightbox script to the DOM friendly slimbox that should also help in these cases.. Thanks for posting the fix..
____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo