CoffeeScript: How to use both fat arrow and this?
问题 I have a coffeescript class that has some jquery event listeners. I would like to use the fat arrow => to avoid having to reference the class, but I still need a reference to the element that would usually be used with this . How can I use both? class PostForm constructor: -> $('ul.tabs li').on 'click', => tab = $(this) @highlight_tab(tab) @set_post_type(tab.attr('data-id')) highlight_tab: (tab)-> tab.addClass 'active' set_post_type: (id) -> $('#post_type_id').val(id) 回答1: CoffeeScript links