Reputation: 3455
How can I call native bind method of function-object with coffeescript ? This is the example of what I am trying to achieve:
window.addEventListener("load",function(e){
this._filter(true);
}.bind(this);
)
Upvotes: 10
Views: 11217
Reputation: 434745
Just add some parentheses around the function so that you can .bind
the right thing:
window.addEventListener('load', ((e) ->
this._filter(true)
).bind(this))
That will use the native bind
method instead of the usual var _this = this
trickery that CoffeeScript's =>
uses.
Upvotes: 14