如何在执行jquery加载之前禁用链接

时间:2010-11-02 04:59:48

标签: jquery

我跟Jquery在一起。

 $(".load-fragment").each(function()         
        {          
            var $objThis = $(this);
            var fname = $objThis.attr("href"); //Getting the href of the element
            var dynDivID = "divContent"+ $objThis.attr("id");  //Name of the dynamic div ID
            var newDiv = $("<div>").attr("id",dynDivID)
            .load(fname+ " #tab-container", {pupdate:"true"},function(response, status, xhr) 
            {               
                //Checking whether response contains class "formContainer" in it or not                
                if( $(response).filter('#tab-container').find('.formContainer').length ) 
                {      
                    ($objThis).unbind("click"); //Removing the attached click event                                                  
                }      
                else
                {
                $("#container-4").append(newDiv);//adding new div in div column2
                }           
                if (status == "error") 
                {               
                    newDiv.removeClass('dynDiv');
                    newDiv.addClass('errorDiv');
                }

            })//Loading page fragment from the given link
            .hide()//Hiding all the newly created DIVs
            .addClass('dynDiv')//Adding CSS to newly created Dynamic Divs
            .append($('<img/>').attr({ src: '/system/Images/ajax-loader.gif', alt: '', style:'margin:50px 0px 50px 185px' }));//Adding the loading.gif file

        });  

现在我要禁用所有其他链接,直到执行JQuery Load,一旦完成,所有其他链接就会像往常一样开始工作。

请建议!

感谢。

1 个答案:

答案 0 :(得分:1)

如果我理解正确,那么最好认为你可以做的是默认禁用所有链接,并在jquery ready函数中启用所有这些链接。