views:

677

answers:

4

I'm successfully using jeditable to submit via a function using jQuery.ajax and the async : false option , but am having an issue aborting if an error is returned.

How can I get the edit box to stay activated and / or revert back to the original value if there are errors? I'm returning http status codes.

so something like

async : false .ajax submit here...
if (xhr.status == 200) {
  return value;
else {
  alert ('returned error');
  // keep edit box activated but available for another try, or revert back to original value
}

I tried not returning a value from the function, which keeps the edit box activated and ready for another submit, but then the ESC key doesn't work anymore and if I click outside the edit area, the edit box stays.

Thanks in advance!

+1  A: 

well, i would like to know that too.. :)

+2  A: 

Not sure if this helps in your situation, but jeditable has a reset method in it...

try...

this.reset();

this will revert the element back to display mode with the original value.

A: 

To stay in editmode,just set response header "HTTP 404" and render a error text.

PHP:

header('HTTP/1.1 400 Bad Request');
echo "Error Text";
Jack
A: 

Add this:

$(this).editable("disable");

This should stop your errors from being editable, not sure about reverting back. I am kinda fighting the same issue with reverting back right now, but i know nothing about JavaScript...

solefald