Skip to content

Instantly share code, notes, and snippets.

@jrunning
Created October 14, 2011 17:33
Show Gist options
  • Save jrunning/1287755 to your computer and use it in GitHub Desktop.
Save jrunning/1287755 to your computer and use it in GitHub Desktop.
CoffeeScripty code
$('#fixHead td.change').click (evt)-> # jQuery will automatically add the event handler to
# every matching element, no need for $.each.
evt.preventDefault() # instead of returning false in an event handler
# (this is a general JS tip, not just CS)
$this = $ this # since you use $(this) twice, just keep it around
$('#contactArea').load $this.data 'content' # parentheses are optional...
$("#ui-dialog-title-dialog").text($this.attr 'title') # but still useful for clarity
centerPopup()
loadPopup()
$('#popupContact').show()
# P.S. Even if we were returning a value here the return keyword is optional--
# the value of the last expression is always returned in CoffeeScript.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment