简体   繁体   中英

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. 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..

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

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 .

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

(Disclaimer: I am mizzao .)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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