Created
March 2, 2012 04:59
-
-
Save andreyfedoseev/1955809 to your computer and use it in GitHub Desktop.
Boilerplate for jQuery plugin in CoffeeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment