On Fri, Apr 23, 2010 at 12:28, Mislav Marohnić <mislav.maroh...@gmail.com>wrote:
> > Here is my implementation: > I noticed there might be a bug with preserving scope in my original implementation. Here is the revised version: Function.prototype.throttle = function(t) { var timeout, fn = this return function() { var scope = this, args = arguments timeout && clearTimeout(timeout) timeout = setTimeout(function() { fn.apply(scope, args) }, t) } } And a usage example: var typingHandler = textarea.on("keyup", function(e) { ... }.throttle(300)) -- You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en