sharepoint中的onready事件

Mar*_*arc 3 javascript sharepoint events sharepoint-2010

我试着打电话new SP.ClientContext.get_current()但是在我这样做的时候我得到一个Cannot read property 'get_current' of undefined错误,因为SP.ClientContext没有初始化.如果我稍后调用该方法,一切正常.

所以我必须等到Sharepoint UI中的所有内容都被加载.怎么做?

我需要一个类似于jQuery 就绪机器人的js ready事件用于Sharepoint UI脚本,可能与SP.SOD但我无法弄清楚如何?

Ric*_*ema 5

你走在正确的轨道上.使用ExecuteOrDelayUntilScriptLoaded在sp.js之后调用您的函数,并在SharePoint页面完全加载后使用_spBodyOnLoadFunctionNames.push调用该函数.

有关更多信息,请参阅Javascript以在页面加载时显示sharepoint列表项.