I’m using this jQuery plug-in for throttle support.
I have a text input variable called textbox set as follows, which will execute someFunction at most once every second:
textbox.keypress($.throttle(1000, someFunction(e)));
However, I want someFunction to execute immediately if the key pressed is the enter key. I’m not quite sure how to do this. Any suggestions?
Keep in mind what you’re passing for callbacks. Both ‘someFunction’ and ‘$.throttle’ are being invoked directly, with their return values being passed as callbacks. To avoid this, wrap the functions in a function (lambda) as I have done above.