which pulls out all the <div class="main-image" data-productid="<%= product.id %>"> divs on the page. Each div is assigned a product id via the ruby script <%= product.id %>
I have a coffeescript function that when hovering a product thumbnail, it switches the main image out with the thumbnail. But right now if you hover a thumbnail it switches out all the main images on the entire page. Thats why I assigned a productid to each and then iterated through each with the above function.
I was hoping I could just replace console.log with all the existing coffeescript, but its not working.
Here's my existing coffeescript that is changing every product on the page:
Wow. I have been stuck on this for two days. And you've gotten me to the point where every image on the page isn't changing! Thank you. However, when you hover a thumbnail it changes the thumbnail out with a big image, not switch the big image out with the thumbnail. Here's my updated coffeescript function:
You can really bash your head against the wall with this stuff and lose site of the small details. A second pair of eyes usually catches the problem right away.
I have the following iteration function:
which pulls out all the
<div class="main-image" data-productid="<%= product.id %>">divs on the page. Each div is assigned a product id via the ruby script<%= product.id %>I have a coffeescript function that when hovering a product thumbnail, it switches the main image out with the thumbnail. But right now if you hover a thumbnail it switches out all the main images on the entire page. Thats why I assigned a productid to each and then iterated through each with the above function.
I was hoping I could just replace console.log with all the existing coffeescript, but its not working.
Here's my existing coffeescript that is changing every product on the page:
How can I add my little
To that whole file, so that all that coffeescript happens inside of the .each iteration?
Thanks so much!
I just sounds like you need to start using a form of
$(this)instead of selecting all.main-imagedivs. So you have this in your mouseenter:But you should just be doing something like this:
Or something similar.
Wow. I have been stuck on this for two days. And you've gotten me to the point where every image on the page isn't changing! Thank you. However, when you hover a thumbnail it changes the thumbnail out with a big image, not switch the big image out with the thumbnail. Here's my updated coffeescript function:
And here's a url to the page: http://pants.telegraphbranding.com/t/women/long-sleeve
Thanks so much for your help. I very much appreciate it.
1) I would add a class of 'product' to each of the products li.
Then you can do something like this:
I'm sorry, I'm not following. Where would you put
I appreciate your help.
Here:
Thank you so much. I've been scratching my head for two days over this one. Your solution works perfectly. I very much appreciate your time.
Awesome!
You can really bash your head against the wall with this stuff and lose site of the small details. A second pair of eyes usually catches the problem right away.