Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
colorbox no longer works after Ajax reload
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Moclvland  
View profile  
 More options Feb 8, 8:28 am
From: Moclvland <maurice.ruel...@gmail.com>
Date: Wed, 8 Feb 2012 05:28:14 -0800 (PST)
Local: Wed, Feb 8 2012 8:28 am
Subject: colorbox no longer works after Ajax reload

Ok, first of all I'm a jQuery newbie.  I've got what i think is an easy
problem to solve but I cant seem to find the answer even after searching
this forum.

I have a galley with multiple pages of images and i'm using ajax to reload
the page of images.  all of the galley images are in a DIV called
#myGallery .  the colorbox links work fine until i reload the div with
another page of images, using ajax.  I realize that colorbox is not being
applied to the newly loaded images but i dont know how to fix it.

Here is what I have in the head of the document.

$(document).ready(function(){
$(".landmark").colorbox({rel:'landmark'});
       var containerId = '#myGallery',
       $container = $(containerId);
       $('a.static_class').live('click', function(e){
              $container.load($(this).attr('href') + '  ' + containerId);
              e.preventDefault();
          });

});

Any help would be appreciated.
Thanks.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Moclvland  
View profile  
 More options Feb 9, 7:27 am
From: Moclvland <maurice.ruel...@gmail.com>
Date: Thu, 9 Feb 2012 04:27:43 -0800 (PST)
Local: Thurs, Feb 9 2012 7:27 am
Subject: Re: colorbox no longer works after Ajax reload

Well I got it to work but I'm not sure why it does.  And I'm sure its not
the proper way to do it.  But I thought I'd post it for others that might
be having the same problem. I was looking at shadowbox, thickbox, lightbox
and others and it seems people are always having trouble with this issue.

I added the code (below) just above the code I originally had.  I had to
create an empty function for it to stop throwing errors, but it seems to be
working fine

 $('#myGallery').click(function(e){
 function fn() {

};

if( $(e.target).is('a') )
fn.call(e.target,e);
$(".landmark").colorbox({rel:'landmark'});

});  

Can anyone tell me why this works or how to improve it?

Thanks.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jack Moore  
View profile  
 More options Feb 9, 3:54 pm
From: Jack Moore <j...@colorpowered.com>
Date: Thu, 9 Feb 2012 15:54:42 -0500
Local: Thurs, Feb 9 2012 3:54 pm
Subject: Re: colorbox no longer works after Ajax reload

> I realize that colorbox is not being applied to the newly loaded images but i dont know how to fix it.

This is correct, and your original code should have been very close to
what you needed.  You just need to assign colorbox again once you have
loaded the new elements into your document.  That means this:

$container.load($(this).attr('href') + '  ' + containerId);

Would become this:

$container.load($(this).attr('href') + '  ' + containerId, function(){
    $(".landmark").colorbox({rel:'landmark'});

--
Jack Moore
jacklmoore.com
twitter.com/jacklmoore

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Maurice Ruelens  
View profile  
 More options Feb 9, 4:09 pm
From: Maurice Ruelens <maurice.ruel...@gmail.com>
Date: Thu, 9 Feb 2012 16:09:26 -0500
Local: Thurs, Feb 9 2012 4:09 pm
Subject: Re: colorbox no longer works after Ajax reload

Wow, so easy and I spent hours trying everything I could think of.  Thanks
so much.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »