jQuery-X可编辑-重置'新记录'提交后 [英] jquery - x-editable - reset 'new record' after submit
问题描述
我一直在试图解决这个问题,但无济于事.
I have been trying to figure this out for hours to no avail.
我有以下内容
http://vitalets.github.com/x-editable/docs.html#newrecord
新记录模块/代码.它的功能是,一旦所有行都有其数据并提交,它就会保留其值,以便保持可编辑状态.
the new record module/code. Its functionality is, once all the rows have their data, and it is submitted, it retains its value so that it can stay editable.
我尝试添加输入,在ajax请求成功时选择清除代码,并尝试将.editable函数放入ajaxComplete函数中,以查看它是否会在提交时重新加载元素,但没有这样做.看演示.输入数据,然后提交.然后将数据设为永久",以便可以继续对其进行编辑.
I have tried adding input, select clearing code in the success of the ajax request and tried putting the .editable function inside an ajaxComplete function to see if it would reload the element on submit but it didnt. look at the demo. enter data, and submit. it then makes the data "permanent" so that it can continue to be editable.
我已删除了隐藏按钮的代码.
I have removed the code that hides the button.
我要执行的操作是,提交记录并重置,以便我可以提交另一张形式为空"并返回默认值的文件.
What i want it to do is, submit the record and reset so i can submit another with the form being 'Empty' and back to default.
我正在开发一种设备跟踪器,希望技术人员可以一次又一次地输入记录.我肯定这是重置表单的简单修复方法,但我无法弄清楚.
I am developing an equipment tracker and would love if techs could just enter records, one after another. im sure its a simple fix to reset the form, i just cannot figure it out.
我已经附上了它的截屏视频.
I have attached a screencast video of it.
http://www.youtube.com/watch?v=dPDuQCgOOSw
推荐答案
作为一个很普遍的问题,我在文档中添加了重置"按钮.
as it's popular question, I've added Reset button to documentation.
$('#reset-btn').click(function() {
$('.myeditable').editable('setValue', null) //clear values
.editable('option', 'pk', null) //clear pk
.removeClass('editable-unsaved'); //remove bold css
$('#save-btn').show();
$('#msg').hide();
});
最好使用 .editable('setValue',null)
而不是 .text('Empty')
,因为我们还需要重置内部值.
HTH
It's better to use .editable('setValue', null)
instead of .text('Empty')
as we need also to reset internal value.
HTH
这篇关于jQuery-X可编辑-重置'新记录'提交后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!