When you have a site that uses Slimbox V2 and upgrade to jQuery 1.9.1 you get a strange behavior. The semitransparent overlay layer comes in front of your image instead of behind it.
Before the upgrade, I used jQuery 1.8 and everything was working fine. Nothing else changed on the site. How to solve the issue without downgrading jQuery?
The problem you have can be easily solved. I've just spend an hour on it myself...
In the minified version of slimbox2, look for the following piece of code:
Now replace that with the following:
Some explanation: Some divs are appended to the body, including lblOverlay (referenced by H in the compiled version). However, if you look at the piece above, by "add"-ing the H variable, it'll be appened to the lblContainer and won't be directly in the body ==> overlay jumps in front of the picture. By adding "end()" to it, you'll only reference the "a"-element, instead of the "a"-element and the overlayer-element.
Tested in FF 20.0.1 and jQuery 1.9.1
Here is the fix I found.
Source: http://code.google.com/p/slimbox/issues/attachmentText?id=36&aid=360003000&name=slimbox2.js
I fixed it in version 2.05.
Here is the diff with the change in the code.
The reason it doesn't work is that jQuery 1.9 changes the way
.after()
works, and the complicated code in the original lightbox that I show below uses.after()
in the old way (assumes it adds the new element to the set of elements returned, whereas the new.after()
doesn't.)You can easily fix it by changing the order, so instead of:
you just do:
However beware. The code below has been changed by me to put the data section above the picture rather than below it, and that needs other changes (you need to add the height of the data section in the
size_container
function). Nevertheless, it's a demonstration of how the problem can be fixed—and is working. See the web site I am working onHm... Fixed Lightbox2 jQuery 1.9.1 - http://www.cybernova.net/javascripts/lightbox.js