Skip to content

Instantly share code, notes, and snippets.

@kapusta
Forked from davidstump/gist:d0b9f87f6a132c2991fb
Last active August 29, 2015 14:06
Show Gist options
  • Save kapusta/937f68910985ec7e5372 to your computer and use it in GitHub Desktop.
Save kapusta/937f68910985ec7e5372 to your computer and use it in GitHub Desktop.
a keyup debouncing directive, needs to be decaffeinated
@App.directive "onDelayedKeyup", ['$timeout', ($timeout) ->
(scope, element, attrs) ->
timer = false
element.bind "keyup", ->
$timeout.cancel(timer) if timer
timer = $timeout ->
scope.$apply attrs.onKeyup
, 500
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment