In Place Edit With Callback

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.

Tagged with: Javascript   Jeditable   Jquery  

Most read tags

Lazy Load   Ruby   AVR  
Electronics   JavaScript  
Jeditable   Maps   jQuery  
Facebook   HTML5   Chained  
Estonia  

Google+