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

FrontEnd Development > Adding Interactivity

I have everything working properly but when I go to edit, Post a new status or delete, the hovering stops working when I return to "All of the Statuses" page.

Simply refreshing the page brings back the desired functionality of having 'Edit' & 'Delete' disappear and re-appear upon hover but just trying to figure out why the refresh is needed.

Loading the page perhaps calls the javascript again to created the desired effect? Still learning how the file structure interacts under ruby.

So statuses.js.coffee is called by application.js I think. My question is what when a page is loaded calles application.js? Just trying to see the chain of events to see why returning to 'All of the Statuses' removes the appearing/disappearing feature.

3 Answers

The javascript is loaded when the page is loaded. Often it is considered strategic to place scripts that need to execute after a page is loaded at the bottom of the page before </body>. Or you could use Jquery's $(document).ready function.

I dont really understand why its not working for you though. Try adding console.log statements in the javascript and watch the developers console as you try to hover over your elements and see whats wrong. Its also better if you can provide some code.

Hey thanks for the reply! Ya like I said it works ok after refresh so somewhat tough for me to debug (especially considering not great with debugging js and rb yet)

Here is the code that I think is pertinent:

index.html.erb application.htlm.erb statuses.js.coffee statuses.css.css

Thanks again and if you need anymore info let me know! Peace!

Just looking over it now basically statuses.js.coffee fails to update the class from 'status' to 'status hovered' unless I refresh the page.

So initially it is fine, then if I do anything (go to edit, delete or create a new post) and go back to 'All of the Statuses', statuses.js.coffee does not work as intended yet if I refresh it works fine.

Thanks again back to more testing.

I'm having the same issue.

I am not alone! Definitely will let you know if I figure it out... may take a little time now to play bug hunter though I am soo new to ruby on rails it is probably something so obvious that I won't figure it out!

Change

.status.hover .admin in .status:hover .admin

in statuses.css.scss

this solves your issue