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

Ruby

Pericles Theodorou
Pericles Theodorou
2,569 Points

Building A Rails App - Adding Interactivity

When I'm writing the code for the hover event,

 $ -> 
    $('.status').hover (event) -> 
      console.log("Hover triggered")

I get the heading in the console but I get no actual reaction to the code.

9 Answers

ADD A SEMICOLON AT THE END.

fixed.

Jody Albritton
PLUS
Jody Albritton
Courses Plus Student 5,497 Points

The only thing that bit of code does is it displays "Hover triggered" in the console, when you over over something with a class of "status". If you are seeing this in the console it is working.

Pericles Theodorou
Pericles Theodorou
2,569 Points

Thanks Jody,

So what is causing the hover event to not actually work?

When I'm hovering over the statuses, edit and delete do not appear

Jody Albritton
PLUS
Jody Albritton
Courses Plus Student 5,497 Points

The relevant code should be

$ ->
$('.status').hover (event) ->
    $(this).toggleClass("hover")

If you have the matching CSS it should appear.

Pericles Theodorou
Pericles Theodorou
2,569 Points

I do have the matching CSS because if I inspect the element and edit it by adding hover class in in the <div class = "status"> it shows the edit and delete options

Jody Albritton
PLUS
Jody Albritton
Courses Plus Student 5,497 Points

Have you downloaded the project files and looked at them?

Pericles Theodorou
Pericles Theodorou
2,569 Points

Yes and everything is matching.

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Try using the mouse enter and mouse leave events separately. I've always found hover to be kind of buggy.