jQuery Small update to jQuery eip plugin. Data parameter is now more flexible. Bug with callback function launching too early is fixed.

In earlier versions you could use functions for two things. To submit edited data to function which takes full control of Ajax request. You could also define optional callback function. This function is called after submitting edited data. Starting from 1.3.1 release you can also use functions as data property. Instead of passing static string you can pass function which generates the data.

This can be used for tricks like parsing out <br /> tags from content.

 <p class="editable">
 Lorem Ipsum.<br /> 
 Dolor sit.<br />
 Amet.
 </p>
 $(document).ready(function() {
     $(".editable").editable("http://www.example.com/save.php", {
         type : "textarea",
         submit : "OK",
         data: function(value, settings) {
             var retval = value.replace(/<br[\s\/]?>/gi, '\n');
             return retval;
         }
     });
 });

Data function receives two parameters. Value contains HTML of clicked element. Settings contain all plugin settings. Inside function this refers to the original element.

Changelog

Bugs fixed:

  • Callback function was called too early.

New features:

  • Data parameter can now be function.

Thanks to Nate Cavanaugh and German Rumm for patches and ideas.

Sorry, comments are closed for this article.