Need a jQuery Lightbox plugin that supports $ .live () and grouping

I bring all my images through Ajax and I am looking for a quick fix for the front-end of this project. I tried a couple of jQuery lightbox plugins, but I can't get them to work in a live function (correct me if I am wrong in thinking that I need to do this).

Currently trying to use the Lightbox plugin from Balupton (I can’t connect due to my new user), and after trying all the examples to no avail, I tried this (also did not work):

$('a.lightbox-gallery').live('click', function(){
    $(this).lightbox();
});

Any help is much appreciated!

+3
source share
3 answers

1) Lightbox 2) ajax, :

$.ajax({
    type: "POST",
    url: "url.php",
    cache: false,
    success: function(data){
        $(data).find('a[rel=lightbox]').lightbox(settings).end().appendTo('#ajaxTarget');
    }
}); 

settings , ;)

+5

colorbox jquery live, ​​

$('a[rel=gallery]').live('click', function() {
  url = this.href; // this is the url of the element event is triggered from
  $.colorbox({href: url});
  return false;
});
+4

You can also take a look at the jquery LiveQuery plugin, which is not a bad plugin;) http://docs.jquery.com/Plugins/livequery you can embed this plugin in your jquery file and use it as a simple jquery function:

$('.ajax-loaded-element').livequery('click',function(){

//do somenthing

});
0
source

Source: https://habr.com/ru/post/1709034/


All Articles