jQuery sort函数冻结一个(上一个)show()文本 [英] jQuery sort function freezing a (previous) show() text

查看:306
本文介绍了jQuery sort函数冻结一个(上一个)show()文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在排列物种清单,但有时列表很大,需要几秒钟才能对其进行排序。因此,我尝试添加一个小的通知,让我们的用户知道有一些运行(他们应该等待)。请查看此页面: http://ibc.lynxeds.com/family/babblers-timaliidae
然后点击排序和过滤[+]。然后,点击任何排序链接。



使用Opera,您将首先收到一条消息,然后开始对物种进行排序,然后将消息更改为不同的文字就是这样。使用FF或IE,第一条消息不显示,您只知道CPU正在做一些工作,然后完成!消息显示并淡出。



所以,在最坏的情况下(缓慢的CPU,大列表),你可能会等待20秒,然后你就完成了!消息(最好显示请等待,完成后才会淡出...)



调用排序功能的JQuery代码是这个:

  $(。s_alf_eng)切换(
function(){
$ .warning)。text(Sorting ... please wait)。show(); //警告是一个空的div
$('。media-status-specie li')sort(sortAscending1) .appendTo('。media-status-specie');
$(。warning)。text(Sorting ... Done!)fadeOut(700);
},
function(){
$(。warning)。text(Sorting ... please wait)。show();
$('。media-status-specie li' .sort(sortDescending1).appendTo('。media-status-specie');
$(。warning)。text(Sorting ... Done!)fadeOut(700);
});

它在Opera中完美无缺。我不明白为什么在其他浏览器中没有显示第一条消息。



我可以如何强制FF和IE在开始排序之前显示请等待消息?



一个相关的问题是如何加快排序(对于最大的家庭来说,在我的core2duo中可能需要20秒)。



感谢您的任何建议!



编辑:排序功能在这里找到:stackoverflow.com/questions/1531176

解决方案

作为测试,如果您更改,会发生什么:

  $('。media-status-specie li')。sort 

to

  $('。media-status-specie')。find('li')。sort .... 

或者更好:

 < ul id =media-status-specieclass =media-status-specie> 

然后:

  $('#media-status-specie')。find('li')。sort ..... 

正如一个FYI,我收到一个关于缓慢运行脚本的浏览器警告消息,我让它运行,它完成了。在我看到你发布的警告信息之前几秒钟。


I'm sorting a list of species, but sometimes the list is large and it takes several seconds to sort it. Thus, I tried adding a small notice to let our users know there's something running (and they should wait). Please just check this page: http://ibc.lynxeds.com/family/babblers-timaliidae And click on "Sort and Filter [+]". Then, click on any "Sort by" link.

With Opera, you will first get a message, then it starts sorting the species, then the message changes to a different text and that's all. With FF or IE, the first message isn't displayed, and you just know the CPU is doing some work, then the "Done!" message is shown and fades out.

So, in the worst case (slow CPU, large list), you might be waiting for 20 seconds and then you get that Done! message (it would be much better to show the "please wait" first, and just fade out when done...)

The JQuery code that calls the sort function is this:

$(".s_alf_eng").toggle(
 function() {
   $(".warning").text("Sorting... please wait").show(); //warning is an empty div
   $('.media-status-specie li').sort(sortAscending1).appendTo('.media-status-specie');
   $(".warning").text("Sorting... Done!").fadeOut(700);
      },
 function() {
   $(".warning").text("Sorting... please wait").show();
   $('.media-status-specie li').sort(sortDescending1).appendTo('.media-status-specie');
   $(".warning").text("Sorting... Done!").fadeOut(700);
      });

It works perfect in Opera. I don't understand why in the other browsers the first message is not shown.

What can I do to force FF and IE to display the "Please wait" message before starting the sort?

A related question is how to speed up the sorting (it can take up to 20 seconds for the largest family, in my core2duo...).

Thank you for any suggestion!

EDIT: The sort function is found here: stackoverflow.com/questions/1531176

解决方案

Just as a test, what happens if you change:

$('.media-status-specie li').sort

to

$('.media-status-specie').find('li').sort....

or, better yet:

<ul id="media-status-specie" class="media-status-specie">

and then:

 $('#media-status-specie').find('li').sort.....

Just as an FYI, I get a browser warning message about slow running script, I let it run and it does finish. It is several seconds before I see the warning message you post by the way.

这篇关于jQuery sort函数冻结一个(上一个)show()文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆