JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 5th, 2012, 01:50 PM
mxbrainwrong mxbrainwrong is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 3 mxbrainwrong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 57 sec
Reputation Power: 0
Newbie question: Jquery hover problem with array of thumbnails

Hi,
I'm having problems with a function and not sure what the answer is. The function is as follows:


function display (array) {
for (i=0, max = array.length; i<max; i++){
var galleryTitle=array[i][3];
var gallerySize=array[i][2];
var galleryDate=array[i][1];
var galleryDescription=array[i][4];

$('#container').append(

'<div id="'+array[i][0]+'" style="position: absolute; left:'+array[i][6]+'px; top: '+array[i][7]+'px;"><a href="#"><img src=images/'+array[i][5]+'></a></div>'
);

$("#"+i).hover(
function () {
$(this).append('<div id="description"><b>Title: </b>'+galleryTitle+'<br /><b>Images: </b>'+gallerySize+'<br /><b>Date: </b>'+galleryDate+'<br /><br />'+galleryDescription+'</div>');
},

function () {
$(this).find("div:last").remove();
}
);
}
}

What I'm trying to do is cause a css box to appear with information about a thumbnail in it, whenever that particular thumbnail is hovered over.

The information and, indeed, the urls of the thumbnails are stored in an array at the start of the script.

The code above works and the css box appears *except* whichever thumb I hover over, only information about the thumbnail identified by the last iteration (is that the right word?) of the for loop appears.

I understand why this is happening (ie, the loop is finished by the time the hover statement comes into being and so 'i' will always be set to the last value) but I can't work out what to do about it. I've tried inserting get element by id calls within the first div but this just seems to knock out the entire script.

I'm happy to post the script in its entirety up here if that helps but thought I;d just hit you all with the bare minimum first.

Any ideas where I should be heading on this?

Many thanks
Stef

Reply With Quote
  #2  
Old March 7th, 2012, 01:50 AM
MariluChester MariluChester is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 8 MariluChester User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 20 sec
Reputation Power: 0
thannk you for this share


Reply With Quote
  #3  
Old March 7th, 2012, 10:55 PM
jaldjoelajeoaj jaldjoelajeoaj is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 4 jaldjoelajeoaj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 17 sec
Reputation Power: 0
Fixed the second one too. Looks like it was just the placement of some of the error message placeholders. For example, the card type error message was set to appear in the middle of the drop down element, which just broke it.URL
URL

Reply With Quote
  #4  
Old March 16th, 2012, 01:50 AM
randy2gray randy2gray is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 4 randy2gray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 57 sec
Reputation Power: 0
Thanks for sharing!!

URL
URL
URL
URL

Reply With Quote
  #5  
Old March 16th, 2012, 02:53 AM
hhvdketi1 hhvdketi1 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 5 hhvdketi1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 57 sec
Reputation Power: 0
Fixed the second one too. Looks like it was just the placement of some of the error message placeholders. For example, the card type error message was set to appear in the middle of the drop down element, which just broke


Reply With Quote
  #6  
Old April 3rd, 2012, 03:33 PM
mxbrainwrong mxbrainwrong is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 3 mxbrainwrong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 57 sec
Reputation Power: 0
Hiya - thanks for your help on this guys - unfortunately, not sure if it's something to do with the forum but was mainly just getting broken image links in what was written. Thanks for the interest anyhow.
S

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Newbie question: Jquery hover problem with array of thumbnails


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap