• I’m developing a small plugin to support some authors. Basically, it loads a (single page style) article page as normal, but cuts short its content and replaces that with a button. That button then loads the rest of the content, after being clicked. (It checks more stuff, of course.)

    Now, my problem is that a lot of lightbox-like script replace or add classnames to images and other content.

    Those scripts have of course already run before my script ever runs.

    Thus: they don’t work because those replacements are never done on the classnames that go with possible additional images. (To name one mediatype.)

    What would be a good way to approach this and get as much scripts as possible to (re)load as possible after my button has done it’s task? (It’s fairly easy to just reload a single script that I know about, but I don’t know what kind of plugins each author runs on their site, of course.)

    Could I just get the page to fire a new document.ready status and hope for the best?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The “correct” way to do this is to attach the function to the element using jQuery’s delegate() function.

    What that will do is bind your event, in your case it’s lightbox’s, to any element on the page, now or in the future, so you can run it when the document loads and it will cover any additional content loaded into it later on.

    Thread Starter ThE_ED

    (@the_ed)

    Thank you, caracaustic.

    Now, my only problem seems to be that these lightboxes and other plugins are not my own. Of course, I can change that on my system, but what about others…

    So I’d need to find a solution that changes the events that are fired document.ready by 3rd parties to delegated events, right?

    You can remove current event handlers using something like .off() or .unbind(). That would let you remove the default event handlers and add your own.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘load and reload Lightbox scripts after I load more content’ is closed to new replies.