【发布时间】:2014-11-21 10:16:52
【问题描述】:
我已经通过 npm 安装了 meteor-typeahead。 https://www.npmjs.org/package/meteor-typeahead 我也安装了
meteor add sergeyt:typeahead
来自https://atmospherejs.com/sergeyt/typeahead
我正在尝试使数据源属性示例正常运行,以便在用户开始键入时显示国家/地区列表。我已将所有国家/地区插入集合中:-
Country = new Meteor.Collection('country');
该集合已发布和订阅。
当我在输入字段中输入时,没有出现任何建议。是否与激活 API 有关?如果是这样,我该怎么做?请参考网站https://www.npmjs.org/package/meteor-typeahead
我的表单如下所示:
<template name="createpost">
<form class="form-horizontal" role="form" id="createpost">
<input class="form-control typeahead" name="country" type="text" placeholder="Country" autocomplete="off" spellcheck="off" data-source="country"/>
<input type="submit" value="post">
</form>
</template>
client.js
Template.createpost.helpers({
country: function(){
return Country.find().fetch().map(function(it){ return it.name; });
} });
【问题讨论】: