HighDots Forums  

Generating onblur funcations

Javascript JavaScript language (comp.lang.javascript)


Discuss Generating onblur funcations in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
botski007@gmail.com
 
Posts: n/a

Default Generating onblur funcations - 12-13-2007 , 12:18 PM






We have a loop that calculates
argValue = someIntegerValue;
component.onblur = function() { callFun( this, argValue ) };
loop

The problem is that the onblur call is exactly "callFun( this,
argValue )" for every component so that the last value of argValue
gets passed to every component.

What we want is this. Assume, for one iteration, argValue had a value
of 16. We want to generate this:
component.onblur = function() { callFun( this, 16 ) };

Any ideas?

Reply With Quote
  #2  
Old   
Stevo
 
Posts: n/a

Default Re: Generating onblur funcations - 12-13-2007 , 12:30 PM






botski007 (AT) gmail (DOT) com wrote:
Quote:
We want to generate this:
component.onblur = function() { callFun( this, 16 ) };
Any ideas?
I have one but it involves eval so I'll wait to see if anyone gives the
proper solution


Reply With Quote
  #3  
Old   
RobG
 
Posts: n/a

Default Re: Generating onblur funcations - 12-13-2007 , 08:58 PM



On Dec 14, 4:18 am, botski... (AT) gmail (DOT) com wrote:
Quote:
We have a loop that calculates
argValue = someIntegerValue;
component.onblur = function() { callFun( this, argValue ) };
loop

The problem is that the onblur call is exactly "callFun( this,
argValue )" for every component so that the last value of argValue
gets passed to every component.

What we want is this. Assume, for one iteration, argValue had a value
of 16. We want to generate this:
component.onblur = function() { callFun( this, 16 ) };

Any ideas?
I think this thread will answer your question:

"Adding events in a loop with arguments"
<URL: http://groups.google.com.au/group/co...0278e9f?hl=en#
Quote:

--
Rob


Reply With Quote
  #4  
Old   
botski007@gmail.com
 
Posts: n/a

Default Re: Generating onblur funcations - 12-14-2007 , 06:13 AM



On Dec 13, 12:30 pm, Stevo <ple... (AT) spam-me (DOT) com> wrote:
Quote:
botski... (AT) gmail (DOT) com wrote:
We want to generate this:
component.onblur = function() { callFun( this, 16 ) };
Any ideas?

I have one but it involves eval so I'll wait to see if anyone gives the
proper solution
OK - I'm ready to see the eval() solution. Thanks.


Reply With Quote
  #5  
Old   
botski007@gmail.com
 
Posts: n/a

Default Re: Generating onblur funcations - 12-14-2007 , 02:36 PM



On Dec 13, 8:58 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote:
Quote:
On Dec 14, 4:18 am, botski... (AT) gmail (DOT) com wrote:

We have a loop that calculates
argValue = someIntegerValue;
component.onblur = function() { callFun( this, argValue ) };
loop

The problem is that the onblur call is exactly "callFun( this,
argValue )" for every component so that the last value of argValue
gets passed to every component.

What we want is this. Assume, for one iteration, argValue had a value
of 16. We want to generate this:
component.onblur = function() { callFun( this, 16 ) };

Any ideas?

I think this thread will answer your question:

"Adding events in a loop with arguments"
URL:http://groups.google.com.au/group/co...browse_frm/thr...



--
Rob
Thanks - that works elegantly.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.