How to reinitialize slimbox2 (lightbox plugin) after ajax call?
-
07-07-2021 - |
Вопрос
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?
Решение
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:
Другие советы
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