获得Meteor Js的下拉值?

时间:2015-02-12 07:39:18

标签: meteor

我使用meteor add sebdah:autocompletion package做了一个示例搜索应用程序。当给出输入时它会显示下拉列表。在此列表中如何获取所选值如下所示代码:

Js代码:

    Friends = new Meteor.Collection('friends');

if (Meteor.isClient) {

  /**
   * Template - search
   */
  Template.search.rendered = function () {
    AutoCompletion.enableLogging = true;
   var res =  AutoCompletion.init("input#searchBox");

   console.log("res :"+res);

  }

  Template.search.events = {
    'keyup input#searchBox': function (e,t) {

      AutoCompletion.autocomplete({
        element: 'input#searchBox',       // DOM identifier for the element
        collection: Friends,              // MeteorJS collection object
        field: 'name',                    // Document field name to search for
        limit: 0,                         // Max number of elements to show
        sort: {name: 1}
      });

    }
  }
}

我对此没有任何想法。所以请建议我如何获取选定的下拉列表值?

1 个答案:

答案 0 :(得分:0)

AutoCompletion包没有提供任何好的API来读取select值。相反,您需要手动读取input#searchBox的值。 请查看source code

我建议使用Arunoda的方法在您的流星应用中实现搜索:https://meteorhacks.com/implementing-an-instant-search-solution-with-meteor.html