Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
api.checklist.com
//Following snippet make the nested tasks collapsible
$("ol.task li").each(function(){
var subtasks = $(this).find(".subtasks ol li");
if(subtasks.length !== 0){
$( $( $(this).children()[0] ).children()[0] ).prepend('<span class="expandable">-</span>');
}
});
$(".expandable").click(function(e){
var subtasks = $(this).parent().parent().next();
if(subtasks.hasClass("collapsed")){
subtasks.removeClass("collapsed");
subtasks.addClass("expanded");
$(this).text("-");
subtasks.show(500);
}else{
subtasks.removeClass("expanded");
subtasks.addClass("collapsed");
$(this).text("+");
subtasks.hide(500);
}
e.preventDefault();
e.stopPropagation();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.