Task List collapse by default

In SharePoint 2013 by rhodzyLeave a Comment

Add an HTML form webpart, replace the source text with this,

<script src=”//code.jquery.com/jquery-1.10.2.js”></script>
<script src=”//code.jquery.com/ui/1.10.4/jquery-ui.js”></script>
<script type=”text/javascript”>
jQuery(document).ready(function($) {
(function($){
function doCollapseTaskList() {
$(“.ms-commentcollapse-iconouter > img”).each(function(){
$(this).click();
});
}
$(function() {
SP.SOD.executeOrDelayUntilScriptLoaded(function () {
if (typeof asyncDeltaManager != “undefined”)
asyncDeltaManager.add_endRequest(doCollapseTaskList);
else doCollapseTaskList();
},’SP.js’);
});

})(jQuery);
});
</script> ​