Resetting Shadowbox's internal cache

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

Resetting Shadowbox's internal cache

fgnass
Hello Michael,

I have a page where some parts are updated via AJAX. These parts may contain Shadowbox links, so I call Shadowbox.setup() after the update, but unfortunately each call doubles the number of entries in the gallery, as the new nodes don't have a shadowboxCacheKey property.

In my scenario the updated HTML may also contain less images than the original, i.e. images can be removed from a gallery. I think an easy way to achieve this would be to have a Shadowbox.reset() method that clears the internal cache array.

Do you think it would be feasible to add such a method in the next release or am I missing something here?

Thanks for your help and this truly beautiful library,
-Felix

Reply | Threaded
Open this post in threaded view
|

Re: Resetting Shadowbox's internal cache

mjijackson
Administrator
The 1.0 version has this capability
Reply | Threaded
Open this post in threaded view
|

Re: Resetting Shadowbox's internal cache

jamesrivers
Can you show an example to how to get this to work properly?  I am also doing something similar.  I have tried the following with varying levels of success:

...
// turns shadowbox off, but does not add reset it
Shadowbox.clearCache();
Shadowbox.setup();
...

...
// ditto, no shadowbox
Shadowbox.clearCache();
Shadowbox.init();
...

...
// Adds the new image to the end of the array (I would prefer to choose where it is inserted), but dimensions are wrong for image (box is normally fills the screen when displaying the new image)
Shadowbox.setup($$("a.newimage"));
...

Thanks for you help.  I have a similar issue with removing an image from shadowbox when an image is deleted from the gallery.

-James
Reply | Threaded
Open this post in threaded view
|

Re: Resetting Shadowbox's internal cache

jontas
Hey,

I ran into the same problem, however, it worked for me using Shadowbox.setup()..  I updated to the newest version today (4/2/08, v1.0), as I had been using a beta release that did not have the clearCache() function.

I don't know why you had trouble using Shadowbox.setup().  The only suggestion I have is look for a post on this forum about a hack to fix the clearCache() function.  The author changed line 2285 from:

delete cache[i].shadowboxCacheKey;

to:

delete cache[i].el.shadowboxCacheKey;

Hope this helps..

Jon
Reply | Threaded
Open this post in threaded view
|

Re: Resetting Shadowbox's internal cache

jontas
Well.. I posted too soon.

The method  I mentioned works fine in Firefox and Safari, but I can't get it working in IE 6 or 7.  Does any one have any ideas?

Jon