jQuery的 - X编辑 - 复位“新纪录”提交后,新纪录、编辑、提交后、jQuery

2023-09-10 18:12:56 作者:斗智斗勇斗小三

我一直在试图找出了这一点数小时无果。

I have been trying to figure this out for hours to no avail.

我有以下

http://vitalets.github.com/x-editable/docs。 HTML#newrecord

新的记录模块/ code。它的功能是,一旦所有的行具有自己的数据,并且它被提交时,它保持其值,以便它可以留编辑。

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.

我已经尝试添加输入,选择结算code在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.

我已删除了code隐藏的按钮。

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.

我重视它的截屏录像。

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('空')因为我们也需要重新设置内部值。 心连心

It's better to use .editable('setValue', null) instead of .text('Empty') as we need also to reset internal value. HTH

 
精彩推荐