Showing description in lightbox using Jquery plugin blueimp gallery

烂漫一生 提交于 2019-12-25 14:40:30

问题


So what i want to do is add a description to the lightbox gallery.

I am using jquery plugin blueimp image gallery and also the bootstrap image gallery plugin over the top. I've searched everywhere but there were only a few posts about it other than what is mentioned within the instructions of the documentation, so figured i'd ask.

i'm sure that's probably whats causing the problem but first i'd like to know if there is a way to add a description preferably underneath the image, it can be under the title too though.

this is the furthest i have got with it using the code below from the blueimp documentation and an additional extra i found from another user demonstrated in the jsfiddle.

      blueimp.Gallery(
      document.getElementById('links'), {
          onslide: function (index, slide) {
          var text = this.list[index].getAttribute('data-description'),
              node = this.container.find('.description');
          node.empty();
          if (text) {
              node[0].appendChild(document.createTextNode(text));
          }
          }
      });

http://jsfiddle.net/2B3bN/37/

this shows how it looks on my webpage, i did manage to implement this but you will however notice that it only works for the first image.

Surely this can be amended with some js? I'm pretty new to js i can read and amend basic js but i'm guessing the same way they change the title can be used to change the description?

Thanks for all the help guys!


回答1:


In case you still need this:

$('#blueimp-gallery').on('slide', function (event, index, slide) {
$(this).children('.description')
    .text($('#links a').eq(index).data('description'));
});


来源:https://stackoverflow.com/questions/21142203/showing-description-in-lightbox-using-jquery-plugin-blueimp-gallery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!