简体   繁体   English

如何显示该Div中的所有列表标题?

[英]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.

相关问题 单击不同的 div(我创建的菜单)时,如何显示和隐藏无序列表? - How do i make an unordered list show and hide when a different div (menu i created) is clicked? jQuery的; 如何显示点击div并隐藏所有其他 - jquery; how do I show the click-on div and hide all the others 如何在TITLE标签上显示JS变量? - How do I show a JS variable on the TITLE tag? 如何根据选定的列表选项在页面加载时显示默认选项卡 (div) - How do I Show a default tab (div) on page load based on selected list option 如何从下拉列表中选择特定的选项值以显示隐藏的div? - How do I select a specific option value from a drop down list to show a hidden div? 如何在 div 中显示 javascript 列表中的所有项目? - How do I display all the items from a javascript list under each other in a div? 在使用 jQuery 在特定结果 div 中单击它后,如何显示所有动态无线电输入值的总和? - How do I show the sum of all dynamic radio input values after I click on it in a specific result div by using jQuery? 如何在页面加载时加载过滤列表中的所有选项? 现在,我必须点击“全部显示”才能做到这一点 - How do I load all options in a filtered list on page load? Right now, I have to click "show all" to make that happen 如何显示一个 div 并隐藏所有其他 div - how can i show one div and hide all the others 如何显示数组的列表元素? - How do I show a of list elements of an array?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM