I am writing a jquery plugin in coffeescript but am not sure how to get the function wrapper part right.
My coffeescript starts with this:
$.fn.exten
The easiest way is to extend $.fn object
Simple jQuery plugin can be written in CoffeeScript as follows:
$.extend $.fn,
disable: ->
@each ->
e = $(this)
e.attr("disabled", "disabled") if e.is("button") or e.is("input")
it will compile to
(function() {
$.extend($.fn, {
disable: function() {
return this.each(function() {
var e;
e = $(this);
if (e.is("button") || e.is("input")) {
return e.attr("disabled", "disabled");
}
});
}
});
}).call(this);