incorrect function call

60 views
Skip to first unread message

Jim

unread,
Mar 23, 2010, 10:45:04 PM3/23/10
to fancybox
I have a fancybox question I have a page that is generated via an ajax
call. That part works fine. However the page which is generated has a
bunch of images I want to group together and display with fancybox. I
have correctly applied the code to those images but the images just
open in a new window. I also tried adding calling fancybox
with .live() that was suggested in another post but it didnt work,
perhaps I did it incorrectly. Below is an example of the type of
function I am calling. Any input would be appreciated.

Jim

Image link:
<a href='xxxx' class="gallery"><img src='xxx' border='0' /></a>

Code:
function xyz () {
$.ajax({

type: "GET",
url: "index.php",
data: "id=" + id,
success: function(output){

setTimeout(
function() {
$("#content")
.empty()
.append(output)
.fadeIn('slow', function(){ xxx })
}, 600);

}
});

//trying to apply fb to new images in content div??
$("a.gallery").fancybox();

}

Jim

unread,
Mar 24, 2010, 7:39:25 PM3/24/10
to fancybox
I got this working. I'd figure I would post in case someone else
needed it. The fancybox call needed to be called 'inside' the success
block of the ajax call. I have read a lot of posts about people with
the same issue but they were trying to call fb in the 'ready' function
which wont work because the content in the div you are loading isnt
there when the page is loaded. You need to initialize it once the
content is there. I hope this helps someone. In my case, it looks like
this...

success: function(output){

setTimeout(
function() {
$("#content")
.empty()
.append(output)
.fadeIn('slow', function(){

xyz;
$("a.fancybox").fancybox();
})
}, 600);

}


On Mar 23, 10:45 pm, Jim <jtbutle...@comcast.net> wrote:
> I have a fancybox question I have a page that is generated via an ajaxcall. That part works fine. However the page which is generated has a


> bunch of images I want to group together and display with fancybox. I
> have correctly applied the code to those images but the images just
> open in a new window. I also tried adding calling fancybox
> with .live() that was suggested in another post but it didnt work,

> perhaps I did it incorrectly.  Below is an example of the type offunctionI am calling. Any input would be appreciated.


>
> Jim
>
> Image link:
> <a href='xxxx' class="gallery"><img src='xxx' border='0' /></a>
>

> Code:functionxyz () {


>         $.ajax({
>
>                         type: "GET",
>                         url: "index.php",
>                         data: "id=" + id,
>                         success:function(output){
>
>                                 setTimeout(
>                                function() {
>                                         $("#content")
>                                         .empty()
>                                         .append(output)

>                                         .fadeIn('slow',function(){ xxx })

Reply all
Reply to author
Forward
0 new messages