我目前正在尝试找出如何从 javascript 获取对 sharepoint 中当前选定列表的引用。如果我知道标题或 ID,我可以得到它,但我希望它根据用户所在的位置动态获取列表。我有这段代码(在我的模式对话框中):
ExecuteOrDelayUntilScriptLoaded(init, 'sp.js');
function init() {
var context = SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getById(SP.ListOperation.Selection.getSelectedList());
}
The problem is that SP.ListOperation.Selection.getSelectedList()
returns null. There is probably some other script I need to wait for - but which one?