I am trying to implement in-place editing in a Rails 3 application that accepts an edited value and revises the calculation based on that value. For instance:
Before editing the "loans for donation" field:
You have 10 credits left. Loans for donation: 0.
After editing the field "donation loans":
You have 5 credits left. Loans for donation: 5.
I looked at various options, and it looks like the jquery-in-place editor does what I'm looking for. For reference:
Demo works. But I think I need to make a callback function to call the ruby script, so I can do some more processing. I'm not quite sure what I need to do, so I'm looking for some kind of guidance.
Here is jQuery jQuery (from /public/javascripts/application.js in the sample application) which, in my opinion, matters:
$("#editme4").editInPlace({
callback: function(original_element, html, original){
$("#updateDiv1").html("The original html was: " + original);
$("#updateDiv2").html("The updated text is: " + html);
return(html);
}
});
It seems like I need to do originaland htmlplay a little with them, and then return them to the appropriate divs. The question is, how do I do this? I think of two possibilities:
A. The jquery-in-place editor has a tool for invoking a URL. Can I use this to call a ruby script and get the result? How do I do this on rails? Here is the code to call url (again from /public/javascripts/application.js); but it calls a php script.
$("#editme1").editInPlace({
// callback: function(unused, enteredText) { return enteredText; },
url: 'server.php',
show_buttons: true
});
B. javascript div. ruby script, , , .