WordPress.org

Ready to get started?Download WordPress

Forums

WP Lightbox 2
Not working on ajax loaded images (3 posts)

  1. mateo-design
    Member
    Posted 1 year ago #

    Hey guys, i think there is a bug with your code;

    I 've noticed that my images( the links around them) that i load with ajax calls arent have the click event triggered on them, so the lightbox is not working on theses new elements,

    I think this comes from a wrong syntax of .on() function;

    line 47:

    return $(this).on("click", onClick);

    this is the syntax for .live() function;

    The jQuery documentation show that :

    $(selector).live(events, data, handler);            //jQuery 1.3+
    $(document).delegate(selector, events, data, handler);//jQuery 1.4.3+
    $(document).on(events, selector, data, handler);      // jQuery 1.7+

    you should bind this way:
    $(document).on("click", this, onClick);

    It worked for me with my own events...

    Thanks!!

    http://wordpress.org/extend/plugins/wp-lightbox-2/

  2. mateo-design
    Member
    Posted 1 year ago #

    or better:

    $(document).on("click", this.selector, onClick);

    works like a charm for me:)

  3. Pankaj Jha
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for suggestion, I will work on this.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic