T
thesimplerules
I have this code which uses Prototype functions:
Event.observe(window, 'load', usinit, false);
function usinit(){
$('submit').style.display = 'none';
Event.observe('UserUsername', 'keyup', warn, false);
}
function warn(target){
var url =
'users/ajaxinterface/Username/'+escape($F('UserUsername'));
var pars = '';
var target = 'us';
var myAjax = new Ajax.Updater(target, url, {method: 'get',
parameters: pars});
}
The problem is I need to make that code re-usable, right now I have to
define the target and form key in the functions and thus would need to
create many functions for a form.
The problem is that the functions usinit and warn, are called by
Prototype and so I can't pass parameters to them - atleast I dont think
I can.
Event.observe(window, 'load', usinit, false);
function usinit(){
$('submit').style.display = 'none';
Event.observe('UserUsername', 'keyup', warn, false);
}
function warn(target){
var url =
'users/ajaxinterface/Username/'+escape($F('UserUsername'));
var pars = '';
var target = 'us';
var myAjax = new Ajax.Updater(target, url, {method: 'get',
parameters: pars});
}
The problem is I need to make that code re-usable, right now I have to
define the target and form key in the functions and thus would need to
create many functions for a form.
The problem is that the functions usinit and warn, are called by
Prototype and so I can't pass parameters to them - atleast I dont think
I can.