2015-02-12 80 views
0

我没有一个样品搜索应用程序中使用流星添加sebdah:自动完成package.When曾经给它输入显示下拉list.In这个名单如何获得选择的值如下所示代码:在流星Js中获取Dropdown值?

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

    } 
    } 
} 

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

回答

0

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

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

+0

是有搜索源包的搜索条件的示例代码@库巴Wyrobek。 – user2344293 2015-02-12 08:28:00

+0

如果您仔细阅读关于搜索源的文章,您会发现它是教程,展示如何在您的应用中构建搜索功能。此外还有[演示应用]链接(https://github.com/meteorhacks-samples/meteor-instant-search-demo)源代码 – 2015-02-12 09:24:05