Skip to content

Instantly share code, notes, and snippets.

@andreyfedoseev
Created March 2, 2012 04:59
Show Gist options
  • Select an option

  • Save andreyfedoseev/1955809 to your computer and use it in GitHub Desktop.

Select an option

Save andreyfedoseev/1955809 to your computer and use it in GitHub Desktop.

Revisions

  1. Andrey Fedoseev revised this gist Mar 2, 2012. No changes.
  2. Andrey Fedoseev created this gist Mar 2, 2012.
    17 changes: 17 additions & 0 deletions jquery.example.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    class Widget
    constructor: (@widget)->
    @input.data("example-widget", @)
    return

    (($)->

    $.fn.exampleWidget = (action, arg)->
    @.each(->
    $this = $(@)
    widget = $this.data("example-widget")
    if not widget
    widget = new Widget($this)
    if action
    widget[action](arg)
    )
    )(jQuery)