• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does anyone have any experience with JEditable

 
J. Kevin Robbins
Bartender
Pie
Posts: 1801
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
J. Kevin Robbins
Bartender
Pie
Posts: 1801
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic