我有一个在流星中使用的自动完成文本框功能。它适用于以下硬编码数据,例如:
$(document).ready(function() {
$("#demo-input-facebook-theme").tokenInput(
[{id: 7, name: "Ruby"},{id: 11, name: "Python"},{id: 13, name: "JavaScript"}],
{theme: "facebook"}
);
});
现在,我已经从数据库 MongoDB 中获取数据,当我将此数据作为参数传递给自动完成功能时,它不起作用......我也使用了该方法JSON.stringify()
。
返回的数据如下所示:
[{"_id":"ab170916-a44b-49f9-85ef-a34c90fb815d","Namelist_name":"Badminton"},
{"_id":"f768e4ba-b628-4d3f-8da6-0bad31346dcc","Namelist_name":"Biking"},
{"_id":"0bee086b-1785-40c9-9c5d-a39331c875e1","Namelist_name":"Chess"},
{"_id":"4eae1e54-ec60-4578-8052-0bf1bccf13b1","Namelist_name":"Golf"},
{"_id":"a0d2b89e-a2d6-4b30-8e38-779c5a886d49","Namelist_name":"Hiking"},
{"_id":"f3a05456-38d4-40f2-86b1-eddea061fdf0","Namelist_name":"Tennis"},
{"_id":"3669b9a2-3f87-4579-8064-82d627196fcb","Namelist_name":"Walking"},
{"_id":"6ac6497e-82b2-40fe-8b24-152e9f42750d","Namelist_name":"Wine Tasting"},
{"_id":"15a7ca87-aef7-43ab-945b-168647bb59aa","Namelist_name":"Yoga"},
{"_id":"bc40d166-64ef-4e61-85cd-60064dc037cd","Namelist_name":"Zumba"}]