I want to be able to do this
$('.class').bind({'click':'function(){ ... }'}); // note that the value is a string
and somehow, checking inside a hooked "bind", that it's indeed a function, and eval()
or new Function
the string, so it will be correctly assigned as an event.
The reason I want to do this is because JSON doesn't allow functions to be defined as values, only strings/ints. I would want to find a way to apply this for all jquery functions (like animate(), click(), live(), etc) that take a handler/function as parameter. it would be a huge hassle and I think, and would become impractical after each new version of jQuery released
Or is there any better way to accomplish this? checking for the first 8 characters if they are === 'function' and then eval it is not a good idea, since it can be a "legitimate" text string. I tried passing a function as a result from a ajax JSON response, but $.parseJSON failed silently.