3

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!

4

3 回答 3

4

不确定这对您的情况是否有帮助,但 jeditable 有一个重置方法......

尝试...

this.reset();

这会将元素恢复为具有原始值的显示模式。

于 2009-06-15T18:30:05.497 回答
0

要保持编辑模式,只需设置响应标头“HTTP 404”并呈现错误文本。

PHP:

header('HTTP/1.1 400 Bad Request');
echo "Error Text";
于 2009-10-23T00:07:28.243 回答
0

添加这个:

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

这应该会阻止您的错误可编辑,不确定是否要恢复。我现在正在与恢复相同的问题作斗争,但我对 JavaScript 一无所知......

于 2010-04-15T23:04:38.010 回答