Snap with coffee letter

How can I call my own method of binding an object function with coffeescript? This is an example of what I'm trying to achieve:

window.addEventListener("load",function(e){ this._filter(true); }.bind(this); ) 
+7
source share
1 answer

Just add parentheses around the function so you can .bind correctly:

 window.addEventListener('load', ((e) -> this._filter(true) ).bind(this)) 

This will use the native bind method instead of the usual var _this = this trick, which uses CoffeeScript => .

+10
source

All Articles