Skip to content

Instantly share code, notes, and snippets.

@dblack
Created April 15, 2012 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dblack/2394369 to your computer and use it in GitHub Desktop.
Save dblack/2394369 to your computer and use it in GitHub Desktop.
Update: I figured it out. I was loading the .js file twice.
In the view:
<%= link_to "Toggle comment", "#", :id => "toggle-comment" %>
<p id="comment" style="display:none;">Comment: <%= @scratchpad.comment %></p>
In the .js file:
$(document).ready(function() {
$("#toggle-comment").click(function() {
$("#comment").toggle('slow');
});
});
Result: clicking on the "hide-comment" link fires off two toggle events, so the
"comment" element goes back to its original state. (I can tell because 'slow'
makes it very visible what's happening.) I can't figure out why this is happening.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment