jQuery Plugin Authoring with CoffeeScript

Hi Guys,

I am using rails-3.1 which use CoffeeScript by default.

Does anybody know how to write jQuery plugin in CoffeeScript according to official jQuery guide?


I knew this:


but I think it’s different from jQuery official guide.

Also, can I remove ‘function-call-this’ wrapper?

If I do that, will I bring myself into another trouble?

I mean: (function() { my code }).call(this);

Thanks :slight_smile:


Hello i'm trying to make this code shorter in coffee script ... what do
you suggest? i'm new to coffee script and just want to know how i would
shorten this command

keyDownHandler = (event) ->
  selectedItem =
  if selectedItem.length > 0
    if event.which is 40
      nextItem =
      nextItem.addClass "current-suggestion" if nextItem.length > 0
    if event.which is 38
      nextItem =
      nextItem.addClass "current-suggestion" if nextItem.length > 0
    if event.which is 13 or event.which is 9

Not sure if it helps but I wrote this: https://gist.github.com/979717

a couple of months ago but I do not know if it adheres to the official guides.