Consider this code
_bindEvents: ->
@input.bind 'keyup', =>
@filter($(this).val())
if $this .val() is ''
@clearBtn.hide()
else
@clearBtn.show()
it’s clear to me that the “@” represents “this.” therefore, it refers to the parent area, but what if I need an “inner this”.
Like this line:
@filter($(this).val())
compiles:
_this.filter($(_this).val());
and I need this:
_this.filter($(this).val());
Is there a way to do this without using the thin arrow and keeping this link manually using closure (that = this)?
source
share