【发布时间】:2014-03-22 12:46:27
【问题描述】:
我正在尝试从显示模板上的共享点列表项中获取所有字段值,ctx.CurrentItem 仅获取一些值,但不是我需要的全部。
我尝试了以下代码,但我得到了标题上的错误
语法错误:无法在“文档”上执行“querySelector”:“[对象 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);
}
【问题讨论】:
标签: javascript jquery sharepoint sharepoint-2010 csom