I get the basic idea of this , not in method , when in strict mode sketched here , but it gets a little erudite to be honest. So, in more prosaic terms:
I have a handler like this:
$('.myClass').one('keyup', function() { var $this = $(this); etc etc });
I want to change it to this:
function myFunction () { var $this = $(this); etc etc }; $('.myClass1').one('keyup', myFunction); $('.myClass2').one('keyup', myFunction); etc
I do not like this because in strict mode , because I use this outside the method. I understand.
However, I need to have myFunction separate from the handler, because (1) it is attached to different classes / elements and (2) I use .off().one('keyup', myFunction) to reset the one handler for different classes at different points .
So, how do I get around using a separate callback function without breaking this business?
source share