Prototype Multi-Event Observation for Multi-Elements
- by Phonethics
['element1','element2','element3'].each(function(e){
Event.observe(e, 'click', function(event){ ... });
Event.observe(e, 'blur', function(event){ ... });
Event.observe(e, 'mousedown', function(event){ ... });
Event.observe(e, 'mouseover', function(event){ ... });
});
Is there a way to reduce this so that I can do
['element1','element2','element3'].each(function(e){
Event.observe(e, ev, function(event){
switch(e){
switch (ev)
}
});
});
?