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?
http://docs.jquery.com/Plugins/Authoring

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:
Kristianto

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 =
$(event.target).siblings(".suggestions").children(".current-suggestion")
if selectedItem.length > 0
if event.which is 40
nextItem =
$(selectedItem).removeClass(“current-suggestion”).next()
nextItem.addClass “current-suggestion” if nextItem.length > 0
return
if event.which is 38
nextItem =
$(selectedItem).removeClass(“current-suggestion”).prev()
nextItem.addClass “current-suggestion” if nextItem.length > 0
return
if event.which is 13 or event.which is 9
addSuggestion(event.target)(selectedItem)
event.preventDefault()
return

Not sure if it helps but I wrote this: Coffeescript implementation of a twitter jquery plugin · GitHub
a couple of months ago but I do not know if it adheres to the official
guides.

On Tue, Oct 4, 2011 at 2:29 AM, Hemant M. [email protected] wrote:

$(selectedItem).removeClass(“current-suggestion”).next()
return
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.