catandmouse
catandmouse

Reputation: 11809

How to reinitialize slimbox2 (lightbox plugin) after ajax call?

We use some ajax to update a photo on a page. But afterwards, the slimbox lightbox no longer works. Previously, it does.

I tried doing:

window.opener.slimbox2();

But it immediately opens the lightbox (as in the screen darkens and a white box appears at the middle). What I'd like is just to get the slimbox2 plugin sort of ready, not immediately pop-out. I tried looking at the js code for slimbox2 but it's already the minified version and it seems that the entire function is automatically called as it has this format:

(function () {
  // code here
})(jQuery);

How do I call it again?

Upvotes: 0

Views: 1328

Answers (2)

catandmouse
catandmouse

Reputation: 11809

We have found a solution to our problem which is actually quite simple. On the anchor tag for the lightbox we just added:

onclick='jQuery.slimbox("[Image URL]"); return false;'

So it looks like this:

<a rel='lightbox' href='image name' onclick='jQuery.slimbox("[Image URL]"); return false;'><img src='image source'></a>

This is the jQuery slimbox2 API for more parameters:

http://code.google.com/p/slimbox/wiki/jQueryAPI

Upvotes: 2

Rahul Dhamecha
Rahul Dhamecha

Reputation: 131

You have to call the javascript function which are used to show the light box or slim box whatever you are using. you have to add "window.opener.slimbox2();" when you have a response text code define your popup code there and it will work for you.

If still it's not work provide me code here so i will guide you

Upvotes: 0

Related Questions