X-Editable放置"Empty"(空)成功更新后 [英] X-Editable putting "Empty" after successful update

查看:357
本文介绍了X-Editable放置"Empty"(空)成功更新后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用X-Editable插件在表上进行内联编辑,但是我遇到了一个烦人的问题.成功请求并成功更新后,插件会在表单元格上放置"Empty"而不是正确的更新值.

I am using X-Editable plugin for inline editing on a table but I am getting a annoying problem. After the successful request and the successful updates, the plugin puts "Empty" instead the correct updated value on the table cell.

我的网站很安静,因此我正在对http://example.com/admin/year/<id>之类的URL进行PUT请求以进行数据库更新.

My site is restful, so I am doing PUT requests to URLs like http://example.com/admin/year/<id> to make database updates.

我制作了一个JSFiddle来展示我的问题,但是在JSFiddle上,X-Editable在ajax请求之后保持无限的加载".看看: http://jsfiddle.net/wqqr3cL3/4/

I've made a JSFiddle to show my problem, but on JSFiddle, the X-Editable keeps the infinite "loading" after ajax request. Take a look: http://jsfiddle.net/wqqr3cL3/4/

谢谢

推荐答案

好!知道了!为了解决此问题,我使用了X-Editable的属性display.因此,从X-Editable display属性文档:

OK! Got it! To solve this problem I used the attribute display of X-Editable. So, from X-Editable display attribute documentation:

回调以在元素的文本中执行值的自定义显示.如果 null,使用默认输入的显示.如果为false,则没有显示方法 将被调用,元素的文本将永远不会改变.在element的下运行 范围.

Callback to perform custom displaying of value in element's text. If null, default input's display used. If false, no displaying methods will be called, element's text will never change. Runs under element's scope.

我更新了代码,并在收到AJAX请求的响应后,以这种方式更新了文本:

I updated my code and after the response from AJAX request, I update the text this way:

//ommited x-editable other code...        
display: function (value, sourceData, response) {
   $(this).html(response.value);
}

这里是一个工作示例,但使用文本框.我用了一个选择框.链接: http://jsfiddle.net/xBB5x/278/

Here an working example but using text box. I used a select box. The link: http://jsfiddle.net/xBB5x/278/

这篇关于X-Editable放置"Empty"(空)成功更新后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆