0

我正在尝试摆脱一个在脚本忙于在新内容中进行 ajax 处理时附加加载 gif 的函数,但我一直在破坏脚本,所以我将它发布在这里希望有人可以为我正确编辑它. (我想摆脱与#load 有关的所有内容,并保持其他所有内容不变。)

    $('#header_nav_content_container a, a.scroll_to_top, a.clear_banner, a.desire').not('.exception').click(function(){ 

    var toLoad = $(this).attr('href')+' #content';
    $('#content').hide(1555,'easeInOutQuint',loadContent);  
    $('#load').remove();
    $('body').append('<span id="load">LOADING...</span>');
    $('#load').fadeIn(888);
    window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-0);
    function loadContent() {
        $('#content').load(toLoad,'',showNewContent);  
    }
    function showNewContent() {
        $('#content').show(777,'',hideLoader);
    }
    function hideLoader() {
        $('#load').fadeOut(888);
    }
    return false;

}); 

谢谢你的帮助。

4

2 回答 2

0

好吧,我想通了。我会在这里发布它,因为我知道很多人都在使用相同的脚本(来自 nettuts 的“加载和动画内容”),所以有人可能想知道如何摆脱脚本的加载部分。

    $('#header_nav_content_container a, a.scroll_to_top, a.clear_banner, a.desire').not('.exception').click(function(){ 

    var toLoad = $(this).attr('href')+' #content';  
    $('#content').hide(1555,'easeInOutQuint',loadContent);  
    window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-0);
    function loadContent() {
        $('#content').load(toLoad,'',showNewContent);  
    }
    function showNewContent() {
        $('#content').show(777,'');  //problem: I needed to remove "hideLoader"
    }
    return false;

});

感谢大家。

于 2012-11-17T04:53:44.427 回答
0
    $('#header_nav_content_container a, a.scroll_to_top, a.clear_banner, a.desire').not('.exception').click(function(){ 

    var toLoad = $(this).attr('href')+' #content';
    $('#content').hide(1555,'easeInOutQuint',loadContent);  



    window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-0);
    function loadContent() {
        $('#content').load(toLoad,'',showNewContent);  
    }
    function showNewContent() {
        $('#content').show(777,'');
    }

    }
    return false;

}); 
于 2012-11-17T04:55:51.733 回答