Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Lightbox: thumbnails OK, background dims, but no large image shows

I have a weird issue where lightbox appears to be working but no larger image appears.

Links to images are correct and thumbnails are showing but no full size image.

There are also no errors in the console.

I have my gallery HTML set up as such:

<a href="images/here.jpg" rel="lightbox[gallery]"><img src="images/here.jpg" alt="FAST Festival Image Gallery"></a>

I have ensured that JQuery, JQuery UI, Lightbox.css, Lighbox.js and jquery.smooth-scroll.min.js are all present.

The page is: http://www.fastfestival.com.au/gallery.html

Does anyone know whats happening at all?

EDIT:

Checking in the console I see there is not image appearing in the Lightbox div when it is envoked

<div id="lightboxOverlay" style="width: 1633px; height: 1234px; display: block;"></div>

like image 277
MeltingDog Avatar asked Feb 04 '13 06:02

MeltingDog


2 Answers

The conflict with jQuery 1.9 has to do with new behavior for the .after() method. You can rewrite the Lightbox.prototype.build method in Lightbox to avoid using the .after() method on disconnected nodes and Lightbox will work with jQuery 1.9 again.

My quickly hacked together solution (that works) follows. It could be cleaned up with more chaining, but I've decided to leave that for later or probably just to wait for Lightbox v2.51 to be revved to include a standardized fix.

Lightbox.prototype.build = function() {
  var $lightbox,
    _this = this;

  // Editing here for jQuery 1.9 conflict
  $("<div>", { "id": "lightboxOverlay" }).appendTo("body");

  lightbox = $("<div>", { "id": "lightbox" });

  outerContainer = $("<div>", { "class": "lb-outerContainer" });
  container = $("<div>", { "class": "lb-container" });
  $(container).append($("<img>", { "class": "lb-image" }));
  nav = $("<div>", { "class": "lb-nav" });
  $(nav).append($("<a>", { "class": "lb-prev" }));
  $(nav).append($("<a>", { "class": "lb-next" }));
  loader = $("<div>", { "class": "lb-loader" });
  $(loader).append($("<a>", { "class": "lb-cancel" }).append($("<img>", { "src": this.options.fileLoadingImage })));
  $(container).append(nav);
  $(container).append(loader);
  $(outerContainer).append(container);

  dataContainer = $("<div>", { "class": "lb-dataContainer" });
  data = $("<div>", { "class": "lb-data" });
  details = $("<div>", { "class": "lb-details" });
  $(details).append($("<span>", { "class": "lb-caption" }));
  $(details).append($("<span>", { "class": "lb-number" }));
  closeContainer = $("<div>", { "class": "lb-closeContainer" });
  $(closeContainer).append($("<a>", { "class": "lb-close" }).append($("<img>", { "src": this.options.fileCloseImage })));
  $(data).append(details);
  $(data).append(closeContainer);
  $(dataContainer).append(data);

  $(lightbox).append(outerContainer);
  $(lightbox).append(dataContainer);

  $(lightbox).appendTo("body");
  // End custom changes

  $('#lightboxOverlay').hide().on('click', function(e) {
    _this.end();
    return false;
  });
  $lightbox = $('#lightbox');
  $lightbox.hide().on('click', function(e) {
    if ($(e.target).attr('id') === 'lightbox') _this.end();
    return false;
  });
  $lightbox.find('.lb-outerContainer').on('click', function(e) {
    if ($(e.target).attr('id') === 'lightbox') _this.end();
    return false;
  });
  $lightbox.find('.lb-prev').on('click', function(e) {
    _this.changeImage(_this.currentImageIndex - 1);
    return false;
  });
  $lightbox.find('.lb-next').on('click', function(e) {
    _this.changeImage(_this.currentImageIndex + 1);
    return false;
  });
  $lightbox.find('.lb-loader, .lb-close').on('click', function(e) {
    _this.end();
    return false;
  });
};
like image 190
jonesbp Avatar answered Oct 17 '22 08:10

jonesbp


It appears that this version of LightBox isnt compatible with the lastest version of JQuery.

I had linked to version 1.9 hosted on Google. I changed to version 1.7 that comes with the download and it works

like image 34
MeltingDog Avatar answered Oct 17 '22 06:10

MeltingDog