你需要复制你的下面的代码
if (toFadeIn.length < 1) { //No results found
toFadeIn.push(noResults);
}
$(toFadeIn).each(function(index, div){
div.fadeIn(1000);
});
的workshop.fadeout的回调函数内..这样的:
workshop.fadeOut(1000, function() {
var tags = $('.left ul li', this);
tags.removeClass('searchMatch'); //reset the search results
tags.each(function() {
if ($(this).text().toLowerCase() === searchTerm.toLowerCase()) {
$(this).addClass('searchMatch');
toFadeIn.push($(this).parent().parent().parent());
}
});
if (searchTerm === "") {
toFadeIn.push(workshop);
}
if (toFadeIn.length < 1) { //No results found
toFadeIn.push(noResults);
}
$(toFadeIn).each(function(index, div){
div.fadeIn(1000);
});
});
你明白吗?该淡出回调尚未调用,但您已经开始浏览toFadeIn
数组以显示搜索结果。那时它甚至还没有搜索过这些参赛作品。
这只是因为我们主要用于顺序代码,所以回调需要一点点头。但它的确如此。您只需继续将代码放入回调中,然后再放入另一个回调中等等。
你能提供一个小提琴吗? – Andre 2011-04-25 13:18:15
如果你能描述出了什么问题(如果有的话),以及报告了哪些错误,这肯定会有很大的帮助。 – Pointy 2011-04-25 13:26:52
[这是你的东西作为jsfiddle](http://jsfiddle.net/xtunh/)。我无法弄清楚它是什么或不该做什么;它目前肯定是*东西*。 – Pointy 2011-04-25 13:35:23