简体   繁体   English

HTML5 localStorage用法

[英]HTML5 localStorage usage

I have a HUGE form that I intend for Quality Assurance personnel to use OFFLINE in the collection of data for Annual Product Quality Reviews. 我有一个巨大的表格,我打算让质量保证人员在年度产品质量评估的数据收集中使用OFFLINE。 Because of the complexity of the regulatory requirements this form contains over 1900 fields and radio-buttons. 由于监管要求的复杂性,此表格包含超过1900个字段和单选按钮。

I have currently invoke localStorage via sisyphus.js and it's working - saving the data for all fields just fine. 我目前通过sisyphus.js调用localStorage并且它正在工作 - 保存所有字段的数据就好了。

My problem is that in loading it takes 7 seconds for the form to finish loading - granted it's a long time - but that's not the real issue. 我的问题是,在加载时,表单需要7秒才能完成加载 - 授予它很长时间 - 但这不是真正的问题。 My REAL problem is that after making any entry it takes a little over 2 seconds after the onblur event for the form to accept any more input. 我的真实问题是,在进行任何输入之后,在onblur事件之后需要花费2秒多的时间让表单接受更多输入。

Here is my code: 这是我的代码:

$('form').sisyphus({
    locationBased: false,
    timeout: 10,
    autoRelease: false
});

My question: is there a way to invoke the storage of data at the discretion of the user, perhaps by a button, or some other method, in order to prevent the constant interruptions in data entry? 我的问题:有没有办法根据用户的意愿调用数据存储,可能是通过按钮或其他方法,以防止数据输入中的持续中断?

Anyone have any ideas? 有人有主意吗?

The plugin you're using (sisyphus.js) doesn't seem to have been written for handling a "large" amount of fields. 您正在使用的插件(sisyphus.js)似乎并不是为处理“大量”字段而编写的。

If you look at the source: 如果你看一下来源:

https://raw.githubusercontent.com/simsalabim/sisyphus/master/sisyphus.js https://raw.githubusercontent.com/simsalabim/sisyphus/master/sisyphus.js

You'll see there's a method saveAllData . 你会看到有一个方法saveAllData Coupled with the bindSaveDataOnChange method, it's saving all fields every time a field is changed. bindSaveDataOnChange方法结合使用,每次更改字段时都会保存所有字段。

And, if that wasn't the case, you'd still get the 2 second lag every 10 seconds (timeout option). 而且,如果不是这种情况,你仍然会每10秒获得2秒延迟(超时选项)。

A quick fix, I'd hope, would be to fork/modify or override the plugin to null out the bindSaveDataOnChange method, and implement a hook for saving the form data on button click. 我希望快速解决方法是分叉/修改或覆盖插件以使bindSaveDataOnChange方法为空,并实现一个钩子,用于在按钮单击时保存表单数据。 And, perhaps, removing or increasing the timeout option. 或许,删除或增加timeout选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM