Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

pfinkbeiner commented Sep 21, 2012

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

This comment has been minimized.

Copy link

ssokolow commented Mar 9, 2013

@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
You can’t perform that action at this time.