aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Does anyone have any experience with JEditable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Does anyone have any experience with JEditable" Watch "Does anyone have any experience with JEditable" New topic
Author

Does anyone have any experience with JEditable

J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 1043
    
  13

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
J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 1043
    
  13

Talking to myself and the duck now...

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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

J. Kevin Robbins wrote:Talking to myself and the duck now...


Heh, I had lunch with the duck.



Sorry, don't know much (anything, actually) about JEditable, but the scenario you describe of getting data to and from the server sounds typical.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Does anyone have any experience with JEditable