Re: using setTimeout when using prototype
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: using setTimeout when using prototype

From: Lasse Reichstein Nielsen <lrn@hotpop.com>
Date: Wed Feb 01 2006 - 02:04:41 CET

"James Black" <planiturthian@gmail.com> writes:

> I have an object, and I define the following:
> var processForm=new Object();

No need to assign an object to the variable when you overwrite
it immediatly afterwards:

> processForm=function(inservleturl) {
> this.inservleturl = inservleturl;
> this.submitForm();
> }
>
> processForm.prototype.submitForm2=function() {

Should this have been "submitStep2"?

> }
>
> processForm.prototype.submitForm=function() {
> setTimeout("submitStep2()", 20);

WHen the first argument to setTimeout is a string, then it
is parsed and executed as a program in the global context.
Even if it wasn't, "submitStep2" is not a variable in
any scope.

> How can the submitForm function's setTimeout call submitStep2?

Try:
                 var self = this;
                 setTimeout(function(){self.submitStep2();}, 20);

/L

-- 
Lasse Reichstein Nielsen  -  lrn@hotpop.com
 DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
  'Faith without judgement merely degrades the spirit divine.'
Received on Tue Feb 7 21:29:28 2006