I'm venturing into some new territory here, making a table with editable fields using DataTables and JEditable. Here's the function that manages the editable fields.
Now, everything works, but here is my concern. That "return(value)" is required for the editable field to return to a non-editable state and display the new value. But since it's outside the ajax call, it's always going to display the new value even if the database update fails. If I put the return inside the "success" function, the editable field doesn't "see" it and stays stuck in editable mode with the old value displayed.
I realize that most people use JEditable by letting it do a POST as soon as the user presses enter, sending the value and element ID. But I'm using the option to send it to a function because I have to get the value of two other fields in the row before I can determine which record is being updated.
I not sure how to work around this one...
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
It looks like I'll have to return a value from the server. So I think I need to do something like this:
save the old value in the database field
attempt to do the update as requested by the ajax call
check for success or failure
build a JSON response with either the old or new value based on whether the update succeeded
return the JSON to the script
parse the JSON
return the value to the "editable" function from the success function
or maybe from a callback of the editable function. It has a callback function available. Not sure about this step yet.
Hmm...probably should create an Ajax handler to do all this instead of stuffing it into an already crowded DAO.
I'll work on this tomorrow. What do you think Mr. Duck? I think it's time to do time sheets, commit code, and get the hell out of Dodge.