[英]How Do I Show All Of The List Title In That Div?
<script type="text/javascript">
window.onload = function() {
ExecuteOrDelayUntilScriptLoaded(ViewItem, 'sp.js');
};
function ViewItem() {
var ctx = new SP.ClientContext.get_current();
this.ListColl = ctx.get_web().get_lists();
ctx.load(this.ListColl);
ctx.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFail));
}
function onSuccess(sender, args) {
var listEnum = this.ListColl.getEnumerator();
while (listEnum.moveNext()) {
var oList = listEnum.get_current();
document.getElementById('resultpanel').innerHTML = oList.get_title();
}
}
function onFail(sender, args) {
alert('FAIL!');
}
</script>
<div id="resultpanel"> </div>
The question is a bit cryptic with only text in Title and code in Body. 这个问题有点神秘,标题中只有文本,正文中只有代码。 I would suggest you go through - How do I ask a good question?
我建议您仔细阅读- 我怎么问一个好问题?
Now coming to the answer. 现在来回答。 If my guess is right then by 'That Div' you mean
<div id="resultpanel"></div>
and assuming your code is working to show Title of only one list then you would have to rework your code something like this: 如果我的猜测是正确的,则用“那个Div”来表示
<div id="resultpanel"></div>
并假设您的代码正在显示仅一个列表的标题,那么您就必须对代码进行如下修改:
var titleOfLists = "";
while (listEnum.moveNext()) {
var oList = listEnum.get_current();
titleOfLists = titleOfLists + oList.get_title() + ", ";
}
document.getElementById('resultpanel').innerHTML = titleOfLists;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.