Skip to content

Instantly share code, notes, and snippets.

@andreapavoni
Created March 1, 2013 14:17
Show Gist options
  • Save andreapavoni/5064928 to your computer and use it in GitHub Desktop.
Save andreapavoni/5064928 to your computer and use it in GitHub Desktop.
A basic example to show how to implement simple/clean jQuery plugins with CoffeeScript
# jQuery custom plugin skeleton with CoffeeScript
class MyPlugin
someMethod: (args) ->
# do something
constructor: (element, params) ->
@someMethod(some_args)
# do something
# install in the window namespace
window.MyPlugin = MyPlugin
# create jQuery plugin
$.fn.myPlugin = (params) ->
new MyPlugin($(@), params)
return $(@)
# Usage:
# $('#element').myPlugin(params)
@andreapavoni
Copy link
Author

(again) nice points, thanks! :-)

I'll think about your concepts and way to integrate them with my approach, you're right (and yes, I'm still a sort-of-noob on this topic :P).

thanks! (repetita iuvant)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment