javascript - adding Picture dynamically to Photoswipe -
i trying add pictures(from array) dynamically photoswipe. have tried use "append" method of jquery without success.i readed people wrote issue on web did not find rigth answer.any helps welcome.
i found way add images dynamically photoswipe, bit hackish.
there 3 tings 1 must do:
- update originalimages (dont know how importent is).
- add click handlers images.
- add images instance.cache.images.
i did following code:
var images, image, i, metadata, src,caption, util =window.code.util; images=$('#addedimages').find('a'); instance.originalimages = $('#all-photo-swipe-images').find('.a'); (i = 0; < images.length; i++) { image = images[i]; src = instance.settings.getimagesource(image); caption = instance.settings.getimagecaption(image); metadata = instance.settings.getimagemetadata(image); image.__photoswipeclickhandler = photoswipe.ontriggerelementclick.bind(instance); util.events.remove(image, 'click', image.__photoswipeclickhandler); util.events.add(image, 'click', image.__photoswipeclickhandler); image = new photoswipe.image.imageclass(image, src, caption, metadata); instance.cache.images.push(image);
Comments
Post a Comment