Javascript array HELP!!!!!

I am using FANCYBOX for a simple image galley.
I want to hold the images in an array

	albums = {
	  album1 : [ {href: '/assets/images/activity1.jpg#v2'}, {href: '/assets/images/activity1.jpg#v2'}],
	  album2 : [ {href: '/assets/images/activty1.jpg#v2'}, {href: '/assets/images/activity1.jpg#v2'}]
	};

	othertest = [ {href : '/assets/images/activity1.jpg#v2'}, {href : '/assets/images/activity1.jpg#v2'} ]


	$('.album-link').bind('click', function(e){
		e.preventDefault();
		var name = $(this).attr('rel');
		console.log(name);
		$.fancybox( albums.name, {});
	});

Open in new window



This code does nothing.

If I put:
            $.fancybox( albums.othertest, {});
it works!

WHY!!!! Must be simple??
Steve TinsleyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve TinsleyAuthor Commented:
forget to show the html

<a href="#" rel="album1" class='album-link'>Album1</a>
<a href="#" rel="album2" class='album-link'>Album2</a>

Open in new window

0
Robert SchuttSoftware EngineerCommented:
The posted code doesn't seem complete to me (albums.othertest is not defined) but you can try:
$.fancybox( albums[name], {});

Open in new window

This means that albums.album1 or albums.album2 will be passed to the function depending on the contents of variable name which seems to me is what you are trying to achieve.
1
Prakash SamariyaIT ProfessionalCommented:
Use like
$.fancybox( albums[name], {});

because name contains the value which is equal to album object's property!!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.