[Javascript] That pesky closure thing :(
Terry Riegel
riegel at clearimageonline.com
Mon Sep 28 13:23:51 CDT 2009
Hello Everyone,
I have a new project I am working on and I think the word closure will
come up in the solution. Something I have not been able to get my head
around.
I have this function
function ajaxForms(c) {
var forms= document.getElementsByTagName('form');
for (i=0; i<forms.length; i++)
{
if (forms[i].className.indexOf(c) != -1)
{
forms[i].onsubmit=function ()
{
new Ajax.Request(
this.action,
{
method: this.method,
parameters: 'ajaxrequest=TRUE&'+riegelSerialize(this),
encoding: 'UTF-8',
onLoading: function (){if(typeof processing == "function")
{processing(this)} }
}
);
return false;
}
}
}
}
I want to take that onLoading line and have it run a function called
processing. The problem I am having is I want to pass "this" to the
processing function. I want this to be the form object forms[i].
Any ideas on how I can accomplish this.
Thanks,
Terry Riegel
More information about the Javascript
mailing list