Alright, I am using the "FancyBox" script to load a larger photo, plus information about the photo into a window, ontop of the window.... which works great. However I need to pass the id (or other unique value) to the javascript so it can pass it on and get the right image and info.

My photo gallery thumbnails are loaded via ajax as well using the $.(#alpha).live('click') method, which should allow me to use jquery on the loaded info (as it has let me in the past).

After I load my gallery it looks similar to:

<div id="photo_gal">
  <div class="picture left" style="height:160px;"><a id="e1" class="the_elevators" href="#1"><img src="thumb.php?im=photographs/c/carrot2.jpg" alt="Carrot River, Saskatchewan" /><br /><div align="center">Carrot River<br />Saskatchewan</div></a></div>
  <div class="picture left" style="height:160px;"><a id="e2" class="the_elevators" href="#2"><img src="thumb.php?im=photographs/c/Carrot_River_01.jpg" alt="Carrot River, Saskatchewan" /><br /><div align="center">Carrot River<br />Saskatchewan</div></a></div>
  <div class="picture left" style="height:160px;"><a id="e3" class="the_elevators" href="#3"><img src="thumb.php?im=photographs/c/cudworth1.jpg" alt="Cudworth, Saskatchewan" /><br /><div align="center">Cudworth<br />Saskatchewan</div></a></div>
  <div class="picture left" style="height:160px;"><a id="e4" class="the_elevators" href="#4"><img src="thumb.php?im=photographs/c/cudworth2.jpg" alt="Cudworth, Saskatchewan" /><br /><div align="center">Cudworth<br />Saskatchewan</div></a></div>
</div>

and the action code is:

$("#photo_gal").fancybox({
		'type': 'custom',
		'see': ??????????
	});

where the ???? is where I need to get the value too. Anyone know how to do this?

Recommended Answers

All 5 Replies

Where does the 'see' option come from ? I cannot find a reference to it on the fancybox.net website. Do you have any more information ?

Sorry, my bad... I made a 'custom' function which is a little cleaner than their ajax method.

case 'custom':
		$.fancybox.showActivity();
		$.get('see.php', {
			"id": selectedOpts.see
		}, function(code) {
			tmp.html(code);
			fancybox_process_inline();
		});
	break;

Basically it does the same thing as the ajax, just a little less code and headache. The "see" variable is passed to the id, but that still doesn't help me get what I need to into that "see" variable.

You can use $(this) in the click to determine your position. I don't think this is possible in the initialization, because you have no active element at that point.

$(this) gives me the #photo_gal area... but I need to identify the individual link that is clicked on in order to show the right photo.

There is no clicked element at the time of initialization, so you can't know.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.