Search code examples
javascriptajaxdrupallightbox2

Drupal's Lightbox2 doesn't appear to work with content inserted via javascript


I'm creating ajax for a Drupal site which loads up new image galleries that need to be lightboxed. The problem, best I can tell, is that lightbox doesn't notice whenever a new anchor is written to the DOM by Javascript.

Is this indeed my problem? Is there any way to have Lightbox2 traverse the DOM again and attach the onclick events to the image links? Better yet, is there some JS way to directly attach Lightbox to an anchor?

JB


Solution

  • If you are using LightBox2 module, try to call from javascript to Drupal.attachBehaviors(document); to attach again the events.