By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,028 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,028 IT Pros & Developers. It's quick & easy.

general function who activate callback on every object - please help

P: n/a
Thank you for your preveious help in the JS forum
can you help my to understand why it is still doesn't work?
I am trying to make a usefull func (ActivateFuncOnObjects3) which can
recieve a list ("obj1,obj2") and activate different func on every
object of the list

thanks

function DisableF2()
{
OBJECT(text).disabled=true;
}

function ActivateFuncOnObjects3(list,Callbackfunction)
{
return function() { Callbackfunction(text); };
}

function ActivateFuncOnObjectsFromList(list,fn)
{
var arr = list.split(',');
for(var i=0;i<arr.length;i++)
{
fn(arr[i]);
}
}

var list='obj1,obj2';
var v3 = ActivateFuncOnObjects3(list,DisableF2)
ActivateFuncOnObjectsFromList(list,v3);

Oct 26 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Montezuma's Daughter wrote:
Thank you for your preveious help in the JS forum
Which "JS forum" are you talking about?
function DisableF2()
{
OBJECT(text).disabled=true;
}
`DiableF2' is unused. `OBJECT' and `text' are undefined. Besides, `OBJECT'
is an identifier unwise to choose, since there is the built-in `Object'.
function ActivateFuncOnObjects3(list,Callbackfunction)
{
return function() { Callbackfunction(text); };
}
`list' is unused.

I recommend you use a source code editor that points out these errors, such
as the JavaScript Editor plugin from Eclipse's Web Development Tools:

<http://download.eclipse.org/webtools/downloads/>
var list='obj1,obj2';
Use Array objects for lists, not comma-separated strings.

Besides, identifiers should start lowercase unless they specify constructors
or constants (just code style).
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Oct 26 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.