检测 Tabulator table 数据是否已更改以提示用户保存数据?

Detect if Tabulator table data has changed to propmt the user to save the data?

我有一个 table,其中数据存储在文本文件中。有一个按钮可以将数据保存回文本文件。如果用户离开页面,任何未保存的数据都将丢失。

有没有办法检测table数据是否发生了变化?然后我可以让用户选择保存还是离开?

有一个 dataEdited 回调,当 table 中的数据被编辑时调用:

var table = new Tabulator("#example-table", {
    dataEdited:function(data){
    //data - the updated table data
    },
});

您可以使用它在其他地方设置一个布尔值,当用户试图离开页面时可以检查该布尔值。

查看 Callbacks Documentation 以了解有关 Tabulator 提供的各种回调的更多信息