Created
March 1, 2013 14:17
-
-
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
This file contains hidden or 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
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(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)