如何通过javascript强制浏览器在对表进行排序之前显示模态
How to force browsers to show a modal before sorting a table via javascript?
我使用的是github上的stupid-table插件。(https://github.com/joequery/Stupid-Table-Plugin)
我正在处理一个非常大的表。Firefox和Chrome在不到3秒的时间内改变了表的排序。IE10、11和Edge需要30秒以上的时间。还有一些移动浏览器,首先是旧iPad 1上的Safari
我想在排序发生之前显示模态' sorting, please wait
',然后在排序结束后隐藏模态。
我试过了:
var super_table = $('#result_div #result_table').stupidtable();
super_table.bind('beforetablesort', function (event, data) {
// data.column - the index of the column sorted after a click
// data.direction - the sorting direction (either asc or desc)
// $(this) - this table object
$('#sorting_modal').modal('show');
console.log('The sorting direction: ' + data.direction);
console.log('The column index: ' + data.column);
});
super_table.bind('aftertablesort', function (event, data) {
// data.column - the index of the column sorted after a click
// data.direction - the sorting direction (either asc or desc)
// $(this) - this table object
$('#sorting_modal').modal('hide');
console.log('The sorting direction: ' + data.direction);
console.log('The column index: ' + data.column);
});
两个问题:
在Firefox和Chrome上,一切都是如此之快,用户现在在屏幕上只看到一个"闪光",所以只会让用户讨厌
在IE上,排序在请求显示模态后立即开始,但是排序是"阻塞"IE的,所以用户在屏幕上看到30秒的"什么都没有发生",然后闪烁(模态显示,表排序,模态隐藏)
理想:
- 用户点击,激活stupid-table插件
- on 'before table sorting'事件我想显示一个模态
- 等待1/2秒
- 做真正的排序
- 在'后表排序'事件我想首先更新表
- 然后隐藏模态,大约在排序结束后1/2秒。
我不知道是否有一种方法来强迫浏览器(和插件本身)"等待"后模态显示之前真正做排序
使用setTimeout来模拟隐藏模态之前的一点延迟:
super_table.bind('aftertablesort', function (event, data) {
// data.column - the index of the column sorted after a click
// data.direction - the sorting direction (either asc or desc)
// $(this) - this table object
setTimeout(function() {
$('#sorting_modal').modal('hide');
}, 1000);
console.log('The sorting direction: ' + data.direction);
console.log('The column index: ' + data.column);
});
相关文章:
- 我想使用模态通过php文件发送邮件,并且我希望在提交关闭后关闭pop
- 打开一个模态并将其链接到AngularJS中的指令
- SemanticUI模态not onDeny/onApprove事件未激发
- 有没有比在app.js上绑定模块名称更好的方法来动态加载视图模型和视图以显示模态
- 如何通过所选索引(AngularJS)在模态弹出窗口中显示数据
- 包含数据库中相关信息的开放模态
- bootstrap消除模态并显示另一个模态
- 模态提示-如何重写此代码
- 模态框无法正常工作
- 将数据传递给由服务创建的Ionic模态
- iframe模态无法关闭
- 点击AngularJS模态窗口捕捉背景事件
- jqueryajax调用是复制url,当在模态视图之后在外部js文件中进行调用时
- 使用模态对话框(JQuery)编辑函数
- 如何在模态实例中使用filter
- 页面上有多个模态框
- 如果满足某些条件,如何在不调用模态的情况下首先调用类
- 在将缩略图链接到模态时遇到问题
- jQuery模态弹出的行为类似于确认和警报对话框
- 如何通过javascript强制浏览器在对表进行排序之前显示模态