SharePoint 2010 中的ExecuteOrDelayUntilScriptLoaded,在2013 中使用时没有效果的问题。
Example:
SharePoint 2013 Code:
SP.SOD.executeFunc(‘sp.js‘, ‘SP.ClientContext‘, sharePointReady);
function sharePointReady() { alert("Ready"); }
SharePoint 2010 Code:
ExecuteOrDelayUntilScriptLoaded(sharePointReady, "sp.js");
function sharePointReady() { alert("Ready"); }
<script type="text/javascript"> ExecuteOrDelayUntilScriptLoaded(GetIdeaItemCount,"sp.js"); var list; function GetIdeaItemCount() { var context = new SP.ClientContext.get_current(); var web = context.get_web(); list = web.get_lists().getByTitle(‘TestFormLib‘); context.load(list); context.executeQueryAsync(Function.createDelegate(this, this.GetSuccess), Function.createDelegate(this, this.GetFailed)); } function GetSuccess(){ document.getElementById("spListItemCount").innerText=list.get_itemCount(); } function GetFailed(sender,args) { alert(‘failed. Message:‘ + args.get_message()); } </script>
Refer: http://msdn.microsoft.com/en-us/library/jj245759.aspx
时间: 2024-10-29 23:09:18