Skip to content
Create a gist now

Instantly share code, notes, and snippets.

More CoffeeScriptish
do ($ = jQuery) ->
$.fn.zebraTable = (options) ->
defaults =
evenColor: '#ccc'
oddColor : '#eee'
options = $.extend(defaults, options)
@each ->
$("tr:even", @).css('background-color', options.evenColor)
$("tr:odd", @).css('background-color', options.oddColor)
@pfinkbeiner

do ($ = jQuery) ->
$.fn.zebraTable = (options) ->
defaults =
evenColor: '#ccc'
oddColor : '#eee'

options = $.extend defaults, options
@each ->
  $("tr:even", @).css 'background-color', options.evenColor
  $("tr:odd", @).css 'background-color', options.oddColor

You can also reduce some ( & )

@ssokolow

@pfinkbeiner It's possible he included the parens on purpose. I know I do in all my CoffeeScript. It means less chance of misunderstanding how a function call is going to be parsed... especially if you code Python rather than Ruby or Haskell.

Also, if you ever see this, edit your comment and indent all your code by 4 spaces. That's the simplest way to indicate a code block in markdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.