Created
April 26, 2015 19:44
-
-
Save jgdovin/e4866ee79a9b539e4940 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nestCategories = function(parentId, dashes) { | |
if (parentId === undefined) | |
parentId = ''; | |
if (dashes === undefined) | |
dashes = ''; | |
var list = []; | |
var categories = Categories.find({parentId: parentId}); | |
categories.map(function(category) { | |
list.push({ | |
label: dashes + ' ' + category.name, | |
value: category._id | |
}); | |
nestCategories(category._id, dashes + '-').map(function(item) { | |
list.push(item); | |
}); | |
}); | |
return list; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment