Skip to content

Instantly share code, notes, and snippets.

@dmohl
Created November 15, 2011 17:23
Show Gist options
  • Save dmohl/1367682 to your computer and use it in GitHub Desktop.
Save dmohl/1367682 to your computer and use it in GitHub Desktop.
CoffeeScript Destructure and Splat Example
do ($) ->
methods =
init: (options) ->
options = $.extend dialogSelector:'.dialog', inputSelector:'.input', options
dialogElement = $(options.dialogSelector)
dialog = dialogElement.dialog autoOpen: false, modal: true, resizable: false
$(options.inputSelector).click -> dialog.dialog 'open'
$.fn.simple = (method) ->
[_, args...] = arguments
if methods[method] then methods[method] args...
else if typeof method is 'object' or not method
methods.init arguments...
else $.error("Method #{method} does not exist in jQuery simple")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment