I did answer this on IRC but you just logged off before I hit send
In case anyone is wonder what the problem is , this line in the view is wrong, len() is not a method in Javascript:
for (var x = 0; x < len(doc.ids); x++) {
It should be:
for (var x = 0; x < doc.ids.length; x++) {