SyntaxError:无法在’Document’上执行’querySelector’:”不是有效的选择器

我试图从显示模板上的sharepoint列表项获取所有字段值,ctx.CurrentItem只获取一些值,但不是我需要的全部。

我尝试了下面的代码,但是我在标题上得到了错误

SyntaxError:无法在’Document’上执行’querySelector’:'[object HTMLDocument]’不是有效的选择器。

function GetListItemById_Success(sender, args) { var id = ListItem.get_id(); var title = ListItem.get_item("Title"); alert("Updated List Item: \n Id: " + id + " \n Title: " + title); } // Display an appropriate error message function GetListItemById_Fail(sender, args) { alert("GetListItemById Failed. \n" + args.get_message() + "\n" + args.get_stackTrace()); } $(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(CustomAction, "sp.js"); }); function CustomAction(){ var clientContext = new SP.ClientContext.get_current(); var web = clientContext .get_web(); var targetList = clientContext.get_web().get_lists().getByTitle('Test Document Library'); var list = web.get_lists().getByTitle('Test Document Library'); ListItem = list.getItemById(ctx.CurrentItem.DocId); clientContext.load(ListItem, "Id", "Title"); clientContext.executeQueryAsync(GetListItemById_Success, GetListItemById_Fail); } 

升级位于顶级站点的jQuery后,我得到了同样的exception。 原因是在子网站母版页中引用了旧的jQuery库。

Interesting Posts