jQuery Colorbox
[resolved] Colorbox for links not working on dynamically created links (3 posts)

  1. alexleonard
    Posted 4 years ago #

    Hey there,

    First let me say that Colorbox is totally awesome. Hands down best lightbox plugin I've used for WordPress :)

    I've been working on a site where I use the colorbox for links functionality a fair bit, and it's been working great so far.

    However I've run into one small issue where it's not working in one place where the link is dynamically placed as a result of a jQuery AJAX call.

    The HTML returned from the AJAX query includes an anchor with a class of 'colorbox-link'. This is working without issue on the rest of the 'static' html links with this class.

    I think it's probably due to use of .bind instead of .on, I think. Certainly I noticed this issue before where I was trying to adjust a dynamically created select option. It only worked when I switched to .on('change', etc {

    Is this something that I could manually over-ride without adjusting the plugin-code, or do I need to hope that a plugin update might fix it?



  2. techotronic
    Plugin Author

    Posted 4 years ago #

    the Colorbox effect is applied to images and links by the JavaScript in the file jquery-colorbox-wrapper.js.
    The main method for you to look at would be colorboxSelector().
    You'll have to call that every time links or images are added to the page with AJAX.


  3. alexleonard
    Posted 4 years ago #

    Hi Arne,

    Thanks for the reply and damn I'm ashamed I didn't respond quicker..

    In the end the client dropped the requirement I needed, but I think I could have handled it by just adding a new colorbox function call in my header.

    I actually did this to give me control over another element which needed to be colorboxed with a different iframe size

        $("#colourbox_newsletter_signup").colorbox({iframe:true, width:"532px", height:"400px"});


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • jQuery Colorbox
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic