how to display number of replies in disscussion board

I have a require about display the replies' number in disscussion board, finish it via jQuery.

First, get the number of the replies of each items via client object model,

then store the number into array.

at last, show it in page via jQuery .

here is the code.

<script type="text/javascript">

      $(document).ready(function(){

                     ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "SP.js");
}); function retrieveListItems() { var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('Dis1'); var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query>' +
'<OrderBy>'+
'<FieldRef Name="DiscussionLastUpdated" Ascending="False"></FieldRef>'+
'</OrderBy>'+
'</Query><RowLimit>20</RowLimit></View>'); this.collListItem = oList.getItems(camlQuery, 'Include(ItemChildCount)'); clientContext.load(collListItem); clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed)); } function onQuerySucceeded(sender, args) { var arr = new Array();
var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();
arr.length = 0;
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
listItemInfo = oListItem.get_item('ItemChildCount');
arr.push(listItemInfo);
} $('#forum0-PostList>li').each(function(index){
$(this).find('div.ms-comm-postMainContainer').css({"float":"left", "width":"90%"});
var arrValue = arr.shift()
$(this).find('div.ms-comm-postMainContainer').after("<div class = 'div_showNumber' style = 'float:left;font-size:20px;width:10%;background-color:gray;color:white;width:30px;height:30px;text-align:center;'>" + arrValue + "</div>");
}); } function onQueryFailed(sender, args) { alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
} </script>

Display number of replies in disscussion board的更多相关文章

  1. Codeforce 835B - The number on the board (贪心)

    Some natural number was written on the board. Its sum of digits was not less than k. But you were di ...

  2. Codeforces Round #427 (Div. 2) Problem B The number on the board (Codeforces 835B) - 贪心

    Some natural number was written on the board. Its sum of digits was not less than k. But you were di ...

  3. Codeforces Round #427 (Div. 2) B. The number on the board

    引子: A题过于简单导致不敢提交,拖拖拉拉10多分钟还是决定交,太冲动交错了CE一发,我就知道又要错过一次涨分的机会.... B题还是过了,根据题意目测数组大小开1e5,居然蒙对,感觉用vector更 ...

  4. [初级教程]用SecureCRT+Xming轻松远程实现Linux的X DISPLAY

    [初级教程]用SecureCRT+Xming轻松远程实现Linux的X DISPLAY 发布者:sqqdugdu 时间:10-06 阅读数:2117 测试环境:RHEL 6.1,SecureCRT 5 ...

  5. System Board Replacement Notice

    System Board Replacement Notice System Board Replacement Notice for TP 770E and TP 600 Restoring the ...

  6. 微信小程序 项目实战(二)board 首页

    1.项目结构 2.页面 (1)数据(逻辑) board.js // pages/board/board.js Page({ /** * 页面的初始数据 */ data: { imgWrap: [] } ...

  7. 一个ICMP单元

    unit ICMPUtils; interface {$IFDEF VER80} { This source file is *NOT* compatible with Delphi 1 becaus ...

  8. Tic-Tac-Toe游戏

    #Tic-Tac-Toe #机器人和人类下井字棋 #全局变量 import random X = "X" O = "O" EMPTY = " &quo ...

  9. 设备管理 USB ID

    发现个USB ID站点,对于做设备管理识别的小伙伴特别实用 http://www.linux-usb.org/usb.ids 附录: # # List of USB ID's # # Maintain ...

随机推荐

  1. Android笔记(二):从savedIndstanceState发散

    savedIndstanceState savedIndstanceState位于ActivityonCreate(Bundle savedInstanceState)方法的参数中.对这个参数的理解要 ...

  2. socket实例2

    第二个实例创建一个java工程,基于tomcat服务器,程序运行时会启动客户端,实现了一个客户端向其他的客户端发送即时信息的功能 MainWindow.java package com.jikexue ...

  3. Bootstrap--导航元素

    1.标签形导航 2.胶囊型导航: 3.垂直堆叠形导航: 4.导航加下拉菜单: 5.导航列表: 6.可切换的标签导航:

  4. superslide2

    标签切换 / 书签切换 / 默认效果 http://www.superslide2.com/demo.html 4个Web前端经典实用值得学习收藏的地图实现模板~ http://www.iteye.c ...

  5. js中的函数,Date对象,Math对象和数组对象

    函数就是完成某个功能的一组语句,js中的函数由关键字 function + 函数名 + 一组参数定义;函数在定义后可以被重复调用,通常将常用的功能写成一个函数,利用函数可以使代码的组织结构更多清晰. ...

  6. css hack 兼容性

    做前端多年,虽然不是经常需要hack,但是我们经常会遇到各浏览器表现不一致的情况.基于此,某些情况我们会极不情愿的使用这个不太友好的方式来 达到大家要求的页面表现.我个人是不太推荐使用hack的,要知 ...

  7. 怎样修复“Windows/System32/Config/System中文件丢失或损坏”故障

    怎样修复“Windows/System32/Config/System中文件丢失或损坏”故障 英文原文引自 http://xphelpandsupport.mvps.org/how_do_i_repa ...

  8. 搭建LNMP架构

    1. 到mysql官方下载一个源码包,尝试编译安装,编译参数可以参考我们已经安装过的mysql的编译参数.操作略,查看mysql编译参数的方法是 cat /usr/local/mysql/bin/my ...

  9. Python学习--07迭代器、生成器

    迭代 如果给定一个list或tuple,我们可以通过for循环来遍历这个list或tuple,这种遍历我们称为迭代(Iteration). Python里使用for...in来迭代. 常用可迭代对象有 ...

  10. JavaScript: Class.method vs Class.prototype.method

    在stack overflow中看到一个人回答,如下   // constructor function function MyClass () { var privateVariable; // p ...