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: https://gist.github.com/909017 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 :) Kristianto -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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. On Tue, Oct 4, 2011 at 2:29 AM, Hemant M. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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 > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >- -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.