JQuery jeditable to remain in edit mode on error

I successfully use jeditable to send through a function using jQuery.ajax and the async: false parameter, but I have an interrupt problem if an error is returned.

How can I make the edit window stay on and / or revert back to its original value if there are errors? I am returning the status of http 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 to return a value from a function that keeps editing the field activated and ready for another, but then the ESC key no longer works, and if I go outside the editing area, the edit box remains.

Thanks in advance!

+3
source share
3 answers

, , jeditable reset ...

...

this.reset();

.

+4

editmode, "HTTP 404" .

PHP:

header('HTTP/1.1 400 Bad Request');
echo "Error Text";
0

Add this:

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

This should prevent your errors from being editable, and not confident in returning back. I seem to be struggling with the same problem, coming back right now, but I don't know anything about JavaScript ...

0
source

Source: https://habr.com/ru/post/1706082/


All Articles