简体   繁体   English

在流星上的mizzao:autocomplete包顶部添加事件

[英]Add event on top of mizzao:autocomplete package in meteor

I am using mizzao:autocomplete package in one of my search field in my application. 我在应用程序的搜索字段之一中使用mizzao:autocomplete软件包。 Autocomplete is working fine and auto-suggestion is coming from my DB. 自动完成工作正常,自动建议来自我的数据库。 As per given in the usage documentation this package using separate template for showing the suggestion list. 根据用法文档中的说明,此程序包使用单独的模板显示建议列表。 Usually when someone select from given suggestion, the list will disappear and selected value appears in the textbox. 通常,当有人从给定建议中进行选择时,该列表将消失,并且所选值将出现在文本框中。

Now what i want is manually trigger some event in title template & do some extra stuff in autoComplete template when someone select some suggestion.. 现在我要手动触发title模板中的某些事件,并在有人选择一些建议时在autoComplete模板中做一些额外的工作。

autoComplete.html autoComplete.html

<template name="autoComplete">
    <div class="col-md-4">
        <h4>Auto Complete</h4>
        {{> inputAutocomplete settings=settings id="jobTitle" class="form-control" name="title" placeholder="Job Title" autocomplete="off"}}
    </div>
</template>

<template name="titles">
    {{title}}
</template>

autoComplete.js autoComplete.js

Template.autoComplete.helpers({
    settings : function() {
        return {
            position: 'bottom',
            limit: 10,
            rules: [
                {
                    collection: JobTitleCollection,
                    field: 'title',
                    matchAll: true,
                    template: Template.titles
                }
            ]
        };
    }
});

You want to use the autocompleteselect event, as described in the docs . 您要使用docs中所述autocompleteselect事件。

Template.foo.events({
  "autocompleteselect input": function(event, template, doc) {
    console.log("selected ", doc);
  }
});

(Disclaimer: I am mizzao .) (免责声明:我是mizzao 。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM