• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Does anyone have any experience with JEditable

 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic