I\'m having trouble attempting to dynamically add images, since lightbox2 (by lokesh dakar) is initialized after document load by existent html
After a couple of hours spent on testing and reading the code, I came up with this magic code:
//set album values
IMG = $('')
.attr('data-lightbox','roadtrip')
.append('
')
//lightbox open:
IMG.click(function(){
lightbox.start($(this));
return false;
})
some helpful tips:
don't set data with $(...).data('lightbox','group')
, since lightbox uses the selector $('a[data-lightbox]')
each time a link is clicked. Instead, you should use $(...).attr('lightbox','group')
.
lightbox.album
is a temporary variable which you don't need to deal with.