簡體   English   中英

使用流星自動完成包搜索(mizzao)

[英]Searching with meteor autocomplete package (mizzao)

我是Java和Meteor的新手,因此無法從Mizzau獲取Meteor自動完成程序包以使其正常工作。 我可以讓表單自動完成就好了,但是很難過濾到我的待辦事項。 我希望最終的結果是在自動完成中輸入待辦事項並過濾訂閱,我也將進行搜索並從那里開始。 我還要說我的初始狀態是列表返回0個待辦事項(未顯示),我感覺自己可能已經關閉。 我的代碼有很大一部分來自於此: 流星-具有“獨特”功能的自動完成功能? T是否與我的訂閱有關?

這是我的服務器端發布調用:

    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);
  }
});

過去,我嘗試使用您遇到麻煩的此自動完成程序包。 我發現它的保真度不足以滿足我的需求。 因此,我向您推薦Twitter typeaheadbloodhound 我對以下軟件包ajduke:bootstrap-tokenfieldsergeyt: typeahead相結合感到非常滿意

時間投資是值得的。 有關示例,請參見我以前的帖子 這里有更多例子。

如果以上內容太復雜,請嘗試jeremy:selectize 關鍵是那里有很多更好的軟件包。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM