views:

36

answers:

1

Hi all, what I'm trying to do is get the ID value of the referring a. The code for my a looks like:

<a class="photoBig" id="<?php echo $photo['id'] ?>" href="<?php echo $f->buildPhotoURL($photo, 'large') ?>" title="<?php echo $photo['title'] ?>">

I'm using phpFlickr to assign the ID's plus some various other things, which works fine.

So the code to open a Fancybox I use is:

$("a.photoBig").attr('rel', 'gallery').fancybox({
            'titleShow'     : true,
            'overlayOpacity' : 0.9,
            'overlayColor' : '#000',
            'autoScale' : false,
            'scrolling' : true,
            'titlePosition' : 'inside',
            'showNavArrows' : true,
            'cyclic' : true,
            'showCloseButton' : false,
            'titleFormat' : formatTitle
        });

then the function fomatTitle, which is:

function formatTitle(title, id, currentArray, currentIndex, currentOpts) {

            return '<div id="photoBig-title"><span><a href="javascript:;" onclick="$.fancybox.close();"><img src="images/site/closelabel.gif"></a></span>' + (title && title.length ? '<strong>' + title + '</strong>' : '' ) + $(this).id + '<a href="http://www.flickr.com/photos/rustybones/' + this.id + '" title="view original on flickr">view full size</a></div>';
        }

Everything works in this function except for this.id. Obviously I'm doing this wrong, so any help would be tops! Thank you.

A: 
bloots
No go, it just returns "undefined".
Rhys
I see that in your function, you are using both $(this).id and this.id. Did you try changing both of them to $(this).attr('id')? What do you mean returns undefined, is that what is said in the box or when you click the link?
bloots
It's in the box, here's a link to what I'm working on: http://bit.ly/9gDA8v
Rhys
Bingo! that did it, cheers!
Rhys