In Place Edit With Callback
March 23rd, 2007
jQuery in place edit is now close to have all features it needs. Add some more and it will become feature creep. Most features are configurable. You can even get full control on Ajax request. Just write your own function for submitting and post to this function instead of URL. Smartypants!.
As usual, download latest source or test online.
Using callback function
Now you can define optional callback function. This function is called after form has been submitted. Callback function receives two parameters. Value contains submitted form content. Settings contain all plugin settings. Inside function this refers to the original element.
$(".editable").editable("http://www.example.com/save.php", {
type : "textarea",
submit : "OK",
}, function(value, settings) {
console.log(this);
console.log(value);
console.log(settings);
});
Submitting to function instead of URL
Parameters passed are now same as with callback. Example below does not do anything useful. It only demonstrates available parameters.
$(".editable").editable(function(value, settings) {
console.log(this);
console.log(value);
console.log(settings);
return(value);
}, {
type : "textarea",
submit : "OK",
});
Note that function must return string. Usually the edited content. This will be displayed on page after editing is done.
Changelog
New features:
- Added support for callbacks.
- If target is function it will receive plugin settings as second parameter.
Bugs fixed:
- Fix problems with IE when style is inherit.
2 Responses to “In Place Edit With Callback”
Sorry, comments are closed for this article.

April 5th, 2007 at 01:25 AM
Is there a way to support XML as the value and then parse it in the callback?
April 7th, 2007 at 01:53 AM
Sorry for the late answer. One option would be to use function instead of url as target parameter. Rewrite the Ajax submitting parts in this function and make it expect XML as return value.
I will write small example about this soon.