【问题标题】:Searching with meteor autocomplete package (mizzao)使用流星自动完成包搜索 (mizzao)
【发布时间】:2015-10-23 21:37:01
【问题描述】:

我是 Javascript 和 Meteor 的新手,在让 Mizzau 的 Meteor 自动完成包正常工作时遇到了一些麻烦。我可以让表单自动完成就好了,但是很难让它过滤我的待办事项。我希望的最终结果是将待办事项输入自动完成并让它过滤订阅,我也会满足于搜索并从那里开始。我还要说我的初始状态是列表返回 0 个待办事项(没有显示)我觉得我可能已经接近了。我的代码中有很大一部分来自:Meteor - autocomplete with "distinct" feature? 吨 是否与我的订阅有关?

这是我的服务器端发布调用:

    Meteor.publish("todosAuto", function(selector, options) {
  Autocomplete.publishCursor(Todos.find(selector, options), this);
  this.ready();
});

我的客户端订阅:

Meteor.subscribe('todosAuto');

我的模板的相关部分:

<div class="container todoFormSec">
    <div class="col-md-4">
      {{> inputAutocomplete settings=settings id="msg" class="form-control" placeholder="Search..."}}
    </div>
  <div class="row">
    <div class="col-md-5 pull-right">
      <h1 class="todocountstyle text-right">You Have {{ todoCount }} Todos</h1>
    </div>
  </div>
  <div class="row">
    <div class="col-md-12">
      <div class="todos">
          {{ #each todosAuto }}
              {{ >todo }}
          {{ /each }}
      </div>
      </div>
  </div>
</div>

还有我的设置:

Template.home.helpers({

  todos: function() {
  return Todos.find();
},


todoCount: function() {
  return Todos.find({userid: Meteor.userId()}).count();
},

  settings: function() {
    return {
      position: "top",
      limit: 5,
      rules: [
        {
          token: '@',
          collection: 'Todos',
          field: "title",
          subscription: 'todosAuto',
          template: Template.titlePill
        },
        {
          token: '#',
          collection: 'Todos',
          field: "categories",
          options: '',
          subscription: 'todosAuto',
          matchAll: true,
          template: Template.dataPiece
        }
      ]
    };
  }

});

Template.home.events({ // listen for selection and subscribe
  "autocompleteselect input": function(event, template, doc) {

   Meteor.subscribe("todosAuto", doc.title);
  }
});

【问题讨论】:

    标签: javascript meteor autocomplete


    【解决方案1】:

    过去我曾尝试使用您遇到问题的这个自动完成包。我发现它的保真度不足以满足我的需求。因此,我向您推荐Twitter typeahead 和bloodhound。我对ajduke:bootstrap-tokenfield 与sergeyt:typeahead 结合使用的以下软件包感到非常满意

    时间投入是值得的。有关示例,请参阅我的 previous posting。 Here 是更多示例。

    如果上面的太复杂,试试jeremy:selectize。关键是那里有很多更好的软件包。

    【讨论】:

    • 我希望本着我所问的精神得到答案,但我会继续接受你的回答。
    猜你喜欢
    • 2018-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-01
    • 2012-01-14
    • 2021-12-03
    相关资源
    最近更新 更多