So, you have to take care of this outside of fancy tree. Basically what we want to do, is pull down the JSON ourselves, and then check its state and render the UI based on that, instead of directly putting it inside of fancy tree
$(function () {
$.get('/documents/folders', function (result) {
if(result.length > 0) {
$("#tree").fancytree({
source: result
});
} else {
$('#tree').html('No documents found!');
}
}).fail(function() {
$('#tree').html('No documents found!');
});
});