Skip to content


JavaScript window.SetTimeout to javascript class method passing object/parameter

I notice people have been struggling with calling a class method and passing a parameter through to it when using the window.setTimeout javascript timer

In my current search engine proejct I am both calling the settimeout method from within my class, assigning the id to a class parameter, incase i want to cancel it before it hapopens, and passing the current call object through to the target class method, setting my delay from a class global delay variable.

The trick is to place an inline function into the expression of the setTimeout call like so :-

Inside my input handler (this is fired from keyup, keydown, paste and various other change events on the page)

Hope this helps those that might have been struggling with this.

Posted in Uncategorized.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.