javascript - 如何保存所有数据

标签 javascript jquery html

我想做的是在用户关闭或刷新浏览器之前使用本地存储保存数据表的当前内容。

我查看了数据表示例 http://datatables.net/beta/1.9/examples/advanced_init/localstorage.html我尝试了代码,但它不起作用。

我的问题是在我当前的代码中,如果我在关闭或刷新页面之前刷新页面或关闭页面并再次打开当前内容,则该代码不起作用,内容消失。

当前代码:http://jsfiddle.net/4GP2h/18/

$(document).ready(function() {
    $('#myTable').dataTable( {
        "bStateSave": true
    } );
} );

最佳答案

dataTable不会将数据表内容存储在localStorage中相反,它存储数据表的状态,例如分页位置、显示长度、过滤和排序。

Enable or disable state saving. When enabled aDataTables will storage state information such as pagination position, display length, filtering and sorting. When the end user reloads the page the table's state will be altered to match what they had previously set up.

有关更多信息,请参阅此链接。

State Save in DataTable

关于javascript - 如何保存所有数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24690651/

相关文章:

javascript - 暂停和更改 CSS3 动画的当前帧?

javascript - 动态添加脚本标签到加载的 HTML - IE7 和 8 中的错误

javascript - 如何更改标题/ View 的颜色

html - 为什么网站会在 HTML 标记中使用 </img>

javascript - 理解 JavaScript promise 对象

javascript - 按钮onclick,执行JS函数再执行JS代码

javascript - 在文本区域中的某些文本下显示错误符号 - 类似于拼写错误行

javascript - 在 PHP 变量中存储 html 页面、解析并显示它的正确方法

javascript - SVG 作为标记图标在 IE 中不起作用

javascript - jQuery 中 .ready() 的必要性