Search code examples
javascriptjqueryjeditable

How to send old version of the field


I use JEditable for making edit field which following code:

       $(function() {
                $(".field").editable("http://localhost/index.php/welcome/update_record", { 
                event  : "mouseover",
                style  : "inherit",
                submit : "save",
                callback: function(value, settings) {
                    //some code
                    }
                });  
    });

I need to update value of the field in the database, but if an user hasn't entered into system with his login/password pair, I need to show message about it and return an old value of the field. So, how can I send the old value of the string too? How can I add it to $_POST array? Thank you.


Solution

  • Here you go - will do it for more than one at a time:

    $(function() {
         $(".field").each(function() {
                var old_value = $(this).text(); //save old value
                $(this).editable("http://localhost/index.php/welcome/update_record", { 
                event  : "mouseover",
                style  : "inherit",
                submit : "save",
                callback: function(value, settings) {
                        $(this).text(old_value);
                    }
                }); 
         });
    
    });