问题
I am trying to integrate the jquery lightbox plugin from here: http://leandrovieira.com/projects/jquery/lightbox/
It is working but only with jquery 1.2.3
When the lightbox is closed and launched the second time, that is when the next and previous links don't cycle through photos properly,
If i click on the next link, the order of photos start to jump like instead of going through photos one by one on click it goes 1, 3, 5 and so on
by the way, this problem happens only when i try to navigate with keyboard arrows, if i use mouse then its fine, but only with keyboard
strange, because i tried to unzip the original provided sample files and I just replaced the jquery version to the newer one and that is when i discovered this problem,
all I did is changed the jquery version from 1.2.3 to any newer one and this is when the problem started
I tried to run the same html in internet explorer, firefox, chrome, safari and even on different computers, but still the same problem
回答1:
Can you post a link to the problem page on the web?
Also, you could try swapping Lightbox for Slimbox2 - it has a nearly identical UI, but may solve the error outright.
回答2:
I solved the problem this way: in the method _set_image_to_view()
add the line _disable_keyboard_navigation();
between lines
_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
and
objImagePreloader.onload=function(){};
Thus the entire method is as follows:
function _set_image_to_view() { // show the loading
// Show the loading
$('#lightbox-loading').show();
if ( settings.fixedNavigation ) {
$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
} else {
// Hide some elements
$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
}
// Image preload process
var objImagePreloader = new Image();
objImagePreloader.onload = function() {
$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);
// Perfomance an effect in the image container resizing it
_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
// for reducing problem with navigation using keyboard (switching some pic at one time)
_disable_keyboard_navigation();
// clear onLoad, IE behaves irratically with animated gifs otherwise
objImagePreloader.onload=function(){};
};
objImagePreloader.src = settings.imageArray[settings.activeImage][0];
};
来源:https://stackoverflow.com/questions/8233177/lightbox-0-5-jquery-compatibility-issue