Re-bind slimbox2 after new AJAX content?

243 views
Skip to first unread message

fullbleedboy

unread,
Jul 27, 2009, 2:29:21 PM7/27/09
to Slimbox
Hi I'm new to jQuery and slimbox2, and I've run into the seemingly
common problem of slimbox not playing nicely with AJAX dynamic
content. The problem is that new content isn't handled by slimbox
after an AJAX update. This seems to be because the new jQuery objects
need to be bound to slimbox. What is the best way to do this? It
partially works when using the Live Query plugin. Slimbox will handle
the links, but galleries don' work. All the images are treated
individually, so one has to click on each link to bring up the slimbox
window. Its exactly as described in the following thread...

http://stackoverflow.com/questions/854130/jquery-slimbox-rebind-after-ajax-callback

And its similar to the old mootools thread in this group. Though the
slimbox.scanPage() function handles this.

http://groups.google.com/group/slimbox-support/browse_thread/thread/be7a5a0399a8959/4663d7b9f6cdaf49?lnk=gst&q=ajax#4663d7b9f6cdaf49

Any suggestions?
Thanks!

jeroen

unread,
Jul 28, 2009, 2:30:03 PM7/28/09
to Slimbox
I remember having problems getting it to work with Live Query as well,
so in the end I resorted to adding:

<script type="text/javascript">
$(document).ready(function() {
$("a[rel^='lightbox']").slimbox({ }, null, function(el) {
return (this == el) || ((this.rel.length > 8) && (this.rel ==
el.rel));
});
});
</script>

to the Ajax output itself. Works perfectly.


On Jul 27, 1:29 pm, fullbleedboy <fullbleed...@gmail.com> wrote:
> Hi I'm new to jQuery and slimbox2, and I've run into the seemingly
> common problem of slimbox not playing nicely with AJAX dynamic
> content.  The problem is that new content isn't handled by slimbox
> after an AJAX update.  This seems to be because the new jQuery objects
> need to be bound to slimbox.  What is the best way to do this?  It
> partially works when using the Live Query plugin.  Slimbox will handle
> the links, but galleries don' work. All the images are treated
> individually, so one has to click on each link to bring up the slimbox
> window.  Its exactly as described in the following thread...
>
> http://stackoverflow.com/questions/854130/jquery-slimbox-rebind-after...
>
> And its similar to the old mootools thread in this group.  Though the
> slimbox.scanPage() function handles this.
>
> http://groups.google.com/group/slimbox-support/browse_thread/thread/b...
>
> Any suggestions?
> Thanks!

fullbleedboy

unread,
Jul 28, 2009, 8:23:33 PM7/28/09
to Slimbox
Brilliant, thanks! I ended up placing the autoload code in my
external file and doing a ('#content').append() after all my other
('#content') updates. Works fine!

Thanks again!

clearglass

unread,
Aug 13, 2009, 4:35:24 PM8/13/09
to Slimbox
I tried both solutions posted and they both aren't working for me.

Parent File (after content updates):
jQuery("#content a").slimbox();
jQuery('#content').append();

External File:
<script type="text/javascript">
jQuery(function($) {
$("a[rel^='lightbox']").slimbox({/* Put custom options here */},
null, function(el) {
return (this == el) || ((this.rel.length > 8) && (this.rel ==
el.rel));
});
});
</script>

Anything I could be doing wrong?

Thanks!
Reply all
Reply to author
Forward
0 new messages