我已经通过npm安装了meteor-typeahead。 https://www.npmjs.org/package/meteor-typeahead 我也安装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; });
} });
谢谢谢尔盖特,我会经历你提到的步骤。 – meteorBuzz 2014-09-26 16:15:58
Meteor.typeahead.inject(选择器);代码去?对不起,我很困惑。 我该如何称呼它? – meteorBuzz 2014-09-26 16:28:09
在DOM就绪事件上调用它,即使用Meteor.startup(演示应用程序有[示例调用](https://github.com/sergeyt/meteor-typeahead/blob/master/demo/demo.js#L165)) 。或者在模板呈现的事件处理器中调用它。 – sergeyt 2014-09-27 15:28:02