我有一個列表視圖的SharePoint Web部件頁面,該列表視圖被分組並且默認爲「摺疊」(非常像基本切換)。 SharePoint生成自己的JavaScript來處理最初的單擊操作,然後擴展頁面區域並動態地將新內容寫入該區域。問題是jQuery無法在點擊後立即訪問新內容(它需要完成加載)。我的想法是添加第二jQuery點擊功能的切換鏈接,並以某種方式等待新的內容添加之前發生任何事情,但我不知道如何確定何時動態內容完成加載...如何通過jQuery訪問動態生成的頁面內容?
//bind a 2nd additional onclick handler via jquery to these items
$('td.ms-gb').children('a').click(function()
{
//give the clicked item a border for visual identification
$(this).css("border","1px solid cyan");
//delay this function until the sharepoint onclick handler finishes loading new content
$('TD.ms-vb-icon').children('a').each(function(index)
{
//give each item a border for visual identification
$(this).css("border","1px solid red");
//perform more jquery on each item
}
);
}
);
我不知道$ .ajaxSuccess()是否適用於未由jQuery函數調用的AJAX。 – gertas
@gertas:我不這麼認爲,但SharePoint的代碼是用jQuery編寫的 –
AFAIK SharePoint沒有發佈jQuery,我認爲你的意思是「JScript」。 [2010年來源](http://blogs.msdn.com/b/publicsector/archive/2010/06/28/does-jquery-ship-with-sharepoint-2010-and-why-you-should-be-using -an-ajax-cdn.aspx) – gertas