Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Matt Campbell
9,767 PointsPuzzling jquery quirk
I've been struggling with jQuery from the off but now I have to get comfortable with it to replicate something for a site I'm doing for my Mum, of all people. She owns a boutique fashion shop and like the Gucci website and the slider it uses to display products. Gucci's attempt sucks and uses Flash. I'm going to use jQuery. Cos it's better and works on everything.
Anyway, here's the thing. The first time the page loads and you click on the picture to make the big info slide out, it doesn't run as it does if you close it and open it again. See http://ultimatewebdevs.co.uk/testspace2/ for a demo. I've only just started working on it and I SUCK at Jquery so it's taking some time. As you can see, the first time something slides out close just appears. The next time it comes in nicely how it is meant to.
I've got doc ready function wrapping all my script. Is this just a jQuery quirk or is there something I can do to sort it out.
One for Andrew Chalkley.
Thanks.
5 Answers
Andrew Chalkley
Treehouse Guest TeacherThe code looks like it works but I think you're only missing the HTML and CSS now.
Regards Andrew
Matt Campbell
9,767 PointsAndrew Chalkley. Thanks for taking a look. The code works as it should, so far, but my issue is this.
The first time you click on an image, it runs slightly differently to the second time you click on it. The word close for example, just appears rather then slide in like it does come 2nd runtime.
As for the HTML and CSS, nows the tricky bit. I need to add a slider to the bottom and buttons for left and right. I need to make it so it focuses the opened one and moves it to the middle of the screen and dims surrounding pictures and when the slider extends past the edge of the screen, when one is opened it moves the slider so it is in the middle of the screen.
I'm finding this a very good exercise in learning jQuery. To be honest, this is how I got to grips with everything else. Just doing it is the best way to learn once you've watched the videos. I reckon now, I'll watch your videos again, Andrew, and the content you discuss will be more relevant and I'll understand it better.
Andrew Chalkley
Treehouse Guest TeacherI think this issue will be fixed with CSS. The .closeOne element is inside of the things that slides out. When you hide the element that slides out it should hide the elements inside. Also the issue could be to do with z-indexing and absolute positioning and having it hidden the way you do.
Matt Campbell
9,767 PointsOK Andrew Chalkley , that makes a little sense. What's the correct way of doing it though? Because, it does it on the elements that don't have .closeOne as well. What's the correct way to hide something like this?
Thanks for all your help. :)
Andrew Chalkley
Treehouse Guest TeacherI don't know off the top of my head. I'd be experimenting. Maybe with wrappers around each element. There's really no right way. Just the ways that work. Once you get it working then you can make it better.