You should put the following section inside the document ready:
$('ul').disableSelection().sortable({
so that it becomes:
function mkUl(){
$("ul").each(function(){
$(this).removeAttr("class");
var ulLevel = $(this).parents('ul').length+1;
$(this).addClass("ui-sortable no-child level_"+ulLevel);
var childC = $(this).children("li").size();
$(this).has("li").removeClass("no-child").addClass("child children-"+childC);
$(this).children("li:first").addClass("first");
$(this).children("li:last").addClass("last");
});
}
$(document).ready(function(){
mkUl();
$('ul').disableSelection().sortable({
connectWith: "ul",
tolerance: "pointer",
cursorAt: {
left: 40,
top: 20
},
cursor: "move",
opacity: 0.5,
placeholder: "highlighter",
helper: "clone",
revert: 200,
start: function(e, ui) {
if(ui.item.parent().hasClass("children-1")){
ui.item.parent("ul").removeClass("child").addClass("no-child");
}
},
stop: function(e, ui) {
mkUl();
}
});
});
Hope this helps