2012-04-26 92 views
2

我寫了一個jQuery腳本來隱藏document.ready中的表格邊框。asp.net更新面板中的jquery腳本

$(document).ready(function() { 
     $(".todotable").last().css("border-bottom", "none"); 
    }); 

此外,我已經把標記放在一個asp.net更新面板中,以便它需要在我需要更新表格時發回整個頁面。複製相同的jquery代碼並將其放置在更新面板中。但是,每次更新面板加載時,不會應用樣式。

找不到問題所在。我是否需要用其他方法替換更新面板中的document.ready?

回答

2

問題是因爲您在每次請求後加載內容,文檔就緒處理程序不會再次調用。

相反,您需要將代碼添加到updatePanel的endRequest事件中。試試這個:

$(function() { 
    // your jQuery code to execute on page load... 
}); 

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function() { 
    // code to execute on updatePanel change 
    $(".todotable").last().css("border-bottom", "none"); 
}); 
+0

你是一個絕對的天才......謝謝。 – Joshua 2012-04-26 09:57:42