Building a frontend and getting a bit baffled since I´m unable to stop the browser to jump when triggering a click event on an img.
I thought that either event.preventDefault() or return false would do it but I am obviously missing something and is completely at a loss about what to try next!
Here is the code
$("#imgViewer-thumbs").find("img").click(function (event) {
event.preventDefault();
var $imgViewPane = $("#imgViewPane"),
$selectedImage = $imgViewPane.find(".selected-image"),
$clickedImage = $(this),
$clickedImageIndex = $clickedImage.prevAll().length + 1,
$maxIndex = $clickedImageIndex + $clickedImage.nextAll().length,
$targetImage = $imgViewPane.find(":nth-child(" + $clickedImageIndex + ")");
if (!$targetImage.hasClass("selected-image")) {
$selectedImage.fadeOut(100, function () {
$targetImage.addClass("selected-image");
$selectedImage.removeClass("selected-image");
$targetImage.fadeIn(100);
});
}
console.log('Returning false');
return false;
}
);
EDIT: Setup the imageviewer in jsfiddle here http://jsfiddle.net/tEXaa/