I'm new to coffee script, so forgive me if this is a simple problem.
I'm trying to make a simple class change when a specific view is loaded in Rails. Specifically I want to run:
$(#mydiv).addClass('active')
In my coffee script, I have the following:
class MyApp.Sessions extends MyApp.Base
constructor:() ->
super # call Base class for core functionality
this # and be sure to return this
index:() ->
$ ->
$('#mydiv').addClass('active')
but the resulting javascript ends up placing my Jquery command outside of the function:
Sessions.prototype.index = function() {
return $(function() {});
};
$('#mydiv').addClass('active');
Any ideas?