How to Hide an Element using Jquery and Coffeescript in Rails?

tetwotenbase

New Member
I would like to hide an element in a page on my Rails site, but I'm not yet that familiar with Jquery or Coffeescript. This code works in the console:\[code\]$('#TheButton').click(function(){$('#TheText').toggle()});\[/code\]I then converted it to Coffescript:\[code\]$("#TheButton").click -> $("#TheText").toggle()\[/code\]But it doesn't work on my Rails page. How do I fix it? Below is the generated javascript file:\[code\](function() {jQuery(function() { # stuff... }); $('form').on('click', '.add_fields', function(event) { # stuff... }); $("#TheButton").click(function() { return $("#TheText").toggle(); });}).call(this);\[/code\]
 
Back
Top