计算器
我有一个ASP项目,我用jQuery管理客户端,我最近学习了这个。
我的项目将一个~400行表加载到GridView。之后可以过滤该表。
我处理过滤所依赖的变量的方式可能不是最有效的,因为过滤需要花费很多时间。但是现在,我还没有想出另一种标记行的方法。
无论如何,我希望在过滤表时使用微调器显示“正在加载”div(这只是在过滤的项目中添加并删除hiddenRow类)。
我尝试使用以下行处理此问题:
$('#loading').fadeIn().promise().done(function(){
//the whole filtering function
});
这段代码有效地显示了加载div,但是我的微调器从不旋转,直到整个表被过滤,从而破坏了div的目的。 div显示,微调器被冻结,表被过滤几秒钟,并且只有在过滤结束后(内存被释放?)才开始旋转。
这里有什么选择?由于我看过一些视频,我考虑使用工作者,但我使用的是 jquery-1.8.3 (这与工作相关,浏览器 IE8 - )和我认为它不受支持。另一个答案提出了一个纯粹的CSS微调器,听起来很不错,但也不支持。我知道我的工具真的很受限制,但有什么我可以做的吗?
答案 0 :(得分:0)
您可以尝试这样的事情
// queue the filtering function after spinner appears
$('#loading').fadeIn().queue(function() {
filteringFunction().done(function() {
// remove the spinner, do other stuff
// this will execute when the filteringFunction is complete
});
});
// use jQuery.Deferred() to synchronize the actions after filtering completes
function filteringFunction() {
var status = $.Deferred();
... // the whole filtering function
status.resolve(); // set this value when your logic is complete
return status;
}
答案 1 :(得分:0)
如果要显示加载图像,请在母版页中保留div并为ajax调用创建全局jquery挂钩,如下所示
<div id="waitImageDiv" >
add your image or message here
</div>
//Global hook-up - show "please wait" when any ajax call is made in the application
$(document).ajaxStart(function () {
$('#waitImageDiv').show();
});
$(document).ajaxStop(function () {
$('#waitImageDiv').hide();
});