Using a variable to define an event listener.
Hello,
I've developed an edit-in-place plugin that I'm presently expanding upon to handle data types other than varchar/blob. Relatedly, I'd like to add the ability to specify what event the plugin should listen for (double click to edit, click to edit, hover to edit, etc)
I've attempted this:
- var defaults = {
- eventType:'dblclick',
//etc
and then...
- function editInPlace(thisObj){
- $(thisObj).unbind(opts.eventType).opts.eventType(function(e){
- makeEditable(thisObj);
- return false;
- });
- };
Not that I expected this to work, mind you :]
My guess is I need to wrap an eval() around the whole shootin' match, but I've read numerous articles citing performance concerns regarding eval(), largely related to Dean Edwards' packer.
Two questions:
1] Would the eval() approach even work as expected? Is there an alternative aside from a ton of conditionals?
2] Are the performance concerns negligible on such a small-scale?