CoffeeScript: How to use both fat arrow and this?

后端 未结 4 1242
既然无缘
既然无缘 2020-12-25 11:55

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 ne

4条回答
  •  有刺的猬
    2020-12-25 13:01

    I prefer this version, because I can understand it more easily.

    class PostForm
        constructor: ->
            post_form = this
    
            $('ul.tabs li').on 'click', (event) ->
                tab = $(this)
                post_form.highlight_tab(tab)
    

提交回复
热议问题