[jQuery] Avoiding anonymous functions - enhancement suggestion

[jQuery] Avoiding anonymous functions - enhancement suggestion


Assigning event functions like click() require an anonymous function
for what is often a very small snippet of code. These anonymous
functions are confusing to inexperienced javascript coders and make
the code less readable, IMO.
I think it would be great to be able to pass a string to these
functions and have it internally turned into a function.
For example, instead of this:
$('#test').click(function() { alert('test'); });
I want to do this:
$('#test').click("alert('test');");
This simple code change seems to do the job:
// Handle event binding
jQuery.fn[o] = function(f){
    return f ? this.bind(o, ((typeof f=="string")?Function(f):f)) :
this.trigger(o);
};
Is it possible to change jQuery to accept a string in addition to a
function reference where possible? Although you would lose the
potential benefit of the closure by passing a string, you could always
pass the function ref instead if you needed to.
Matt Kruse