Ruby on Rails
Tuesday, October 4, 2011
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@ruby-forum.com> 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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment