I am using https://github.com/Meteor-Community-Packages/meteor-autocomplete
I would like to know how I can preselect/prepopulate a value in autocomplete input text. If that is not possible is there any way to set a default value? HTML value="default" does not work.
I am trying to use it in an email composer's to, cc, bcc fields. By default the input fields have some default user selected, ( it may be different depending on case) but they can change it using the search in autocomplete.
Here is my code ( sorry there was no option to edit, hence replying from my other account)
settings() {
return {
position: 'bottom',
limit: 80,
rules: [
{ // token: '',
collection: Subscribers,
sort: true,
field: 'status',
matchAll: true,
filter: { status: { $ne: 'deleted' } },
template: Template.standardSubscribers,
selector(match) {
let regex;
regex = _.map(match.split(' '), function(key) { return new RegExp('^' + key, 'i'); });
return {
'$or': [
{ 'firstName': { '$in': regex } },
{ 'lastName': { '$in': regex } },
{ 'email': { '$in': regex } },
{ 'address': { '$in': regex } },
{ 'secondaryEmail': { '$in': regex } },
{ 'businessName': { '$in': regex } }
]};
},
}
]
};
},
<template name="standardSubscribers">
<span class="">{{businessName}} {{#if isBusinessName businessName}} -- {{/if}} {{firstName}} {{lastName}} -- {{email}} -- {{secondaryEmail}} -- {{status}} -- {{address}}</span>
'autocompleteselect #email-to' (event, template, doc) {
if (doc.businessName) {
event.target.value = doc.businessName + '<' + doc.email + '> --- ' + doc.status;
} else {
event.target.value = doc.firstName + ' ' + doc.lastName + '<' + doc.email + '> --- ' + doc.status;
}
},
{{> inputAutocomplete settings=settings style="width: 73%" value="yogesh" id="email-cc" class="form-control" name="emailCC" autocomplete="off" }}
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.