dynamically adding new shadowbox galleries after initial call to init.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

dynamically adding new shadowbox galleries after initial call to init.

brco3837
Sorry for the long subject line but I figured it actually summed up the subject pretty good. :) Currently I'm actually trying to use shadowbox with the jQuery library 1.1.4. Everything works perfect in FF but unfortunately not in IE. When I start off, I'm actually dynamically creating my content and then calling
options = {
    resizeLgImages:     true,
    displayNav:         true,
    handleUnsupported:  'link',
    keysClose:          ['c', 27], // c or esc
    autoplayMovies:     true
};
Shadowbox.init(options) 
when the dom is finished loading. After this, I have a sort function written in javascript that basically creates another table. The new links that I create don't have the shadowbox functionality so I call:
Shadowbox.setup(null, shadowboxOptions);
to add the shadowbox functionality into the new links. Again, this works fine in FF but in both IE6 and IE7 it seems to just choke. Is there any particular way that I need to implement Shadowbox on these new anchors or am I doing it right and just missing something? Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: dynamically adding new shadowbox galleries after initial call to init.

mjijackson
Administrator
Usually you would pass in an array of anchor elements as your first argument in Shadowbox.setup. As far as I know, you could also just pass in the jQuery object directly. I don't use jQuery that much, so I haven't tried it.
Reply | Threaded
Open this post in threaded view
|

Re: dynamically adding new shadowbox galleries after initial call to init.

brco3837
Actually I was originally passing in the null to let shadowbox handle the dynamic setup on all of the elements but unfortunately that wasn't working so I ended up passing in the array of newly created anchors. Again, this worked great in FF but not in any version of IE. I'm just using:
var anchors = jQuery("#files").find("a.preview").get()
Shadowbox.setup(anchors);
which in jQuery actually returns the array of anchors. Again it didn't work in ie. Any ideas on why?
Reply | Threaded
Open this post in threaded view
|

Re: dynamically adding new shadowbox galleries after initial call to init.

brco3837
In reply to this post by mjijackson
I did end up figuring out the problem, I was actually copying the elements over from one table to another and even though the elements weren't holding onto their click handlers after the copy they were holding on to the shadowboxCacheKey attribute and the shadowbox click handler was never getting added.
To fix this I just use newElem.removeAttr("shadowboxCacheKey") and it works perfectly