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 trialEleanor Campbell
8,630 PointsTask 1 keeps failing on task 2 in Challenge.
I pass task 1, then go to task 2 and check my work. Even when I don't change a single thing it tells me that task one is no longer passing. What is going on? Is this one of the bugs we are suppose to fix? Does the challenge change our code between task one and two?
Eleanor Campbell
8,630 Pointsahhhhh. I meant that to be a comment. Sorry new to using this forum. so see my comment in the answer section.
4 Answers
Eleanor Campbell
8,630 PointsYeah I couldn't find the forum for the challenge. it's the one immediately following this video. "fixing the simple lightbox". here's the code, I put my changes between ***** (obviously I did not actually put these in the challenge just here to make it easy to see my changes): //Problem: User when clicking on image goes to a dead end //Solution: Create an overlay with the large image - Lightbox
var $overlay = $('<div id="overlay"></div>'); var $image = $("<img>"); var $caption = $("<p></p>");
//An image to overlay $overlay.append($image);
//A caption to overlay $overlay.append($caption);
//Add overlay $("body").append($overlay);
//Capture the click event on a link to an image $("#imageGallery a").click(function(event){ **$event.preventDefault();** var imageLocation = $(this).attr("href"); //Update overlay with the image linked in the link $image.attr("src", imageLocation);
//Show the overlay. $overlay.show();
//Get child's title attribute and set caption var captionText = $(this).children("img").attr("**title**"); $caption.text(captionText); });
//When overlay is clicked $overlay.click(function(){ //Hide the overlay $overlay.hide(); });
Heather Ingram
11,094 PointsFor the first step I added event.preventDefault(); to the click event like you did with no issues. On the second part, I just changed alt to title.
Justin Phillips
7,177 PointsHas anyone been able to pass task 2? I've done the same as Heather (comment above), passed Task 1, but Task 2 says that Task 1 is no longer passing!
Omar Elfishawi
4,060 PointsIm having the same problem, task 1 is no longer passing /Problem: User when clicking on image goes to a dead end //Solution: Create an overlay with the large image - Lightbox
var $overlay = $('<div id="overlay"></div>'); var $image = $("<img>"); var $caption = $("<p></p>");
//An image to overlay $overlay.append($image);
//A caption to overlay $overlay.append($caption);
//Add overlay $("body").append($overlay);
//Capture the click event on a link to an image $("#imageGallery a").click(function(event){ event.preventDefault();
//Update overlay with the image linked in the link $image.attr("src", imageLocation);
//Show the overlay. $overlay.show();
//Get child's title attribute and set caption var captionText = $(this).children("img").attr("title"); $caption.text(captionText); });
//When overlay is clicked $overlay.click(function(){ //Hide the overlay $overlay.hide(); });
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsBrendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsWhich challenge? This question seems to be linked to a video not a challenge.
Also can you post the code that you attempted?