Skip to content

Instantly share code, notes, and snippets.

@rettal
Created October 12, 2015 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rettal/3da63a1e165a18283fd2 to your computer and use it in GitHub Desktop.
Save rettal/3da63a1e165a18283fd2 to your computer and use it in GitHub Desktop.
function getList(item, $list) {
if($.isArray(item)) {
$.each(item, function (key, value) {
getList(value, $list);
});
return;
}
if (item) {
var $li = $('<li />');
if (item.name) {
$li.append($("<p style='margin-bottom:0px'>"+item.name+"</p>"));
}
if (item.errors && item.errors.length) {
var $sublist = $("<ul/>");
getList(item.errors, $sublist)
$li.append($sublist);
}
$list.append($li)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment