JQueryオートコンプリート「複数」を使用して電子メールを取得する必要がある場合は、アプリケーションスクリプトを使用してgetContacts()をコーディングするにはどうすればよいですか?ContactsAppから連絡先を取得する
それは、人は、単一の名前で保存された2つの電子メールIDを持っている場合、それはJSON配列を返すに追加する必要がありますように返す必要があります。
例PERSON.Aが[email protected]と[email protected]を持っているならば、リストには、電子メールの配列を取得と仮定
var emails = [
"PERSON.A" <[email protected]>,
"PERSON.A" <[email protected]>,
...
];
javascriptの
emails = google.script.run.getContacts();
$(function() {
var availableTags = emails;
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}
$("#recipients")
// don't navigate away from the field on tab when selecting an item
.on("keydown", function(event) {
if (event.keyCode === $.ui.keyCode.TAB &&
$(this).autocomplete("instance").menu.active) {
event.preventDefault();
}
})
.autocomplete({
minLength: 0,
source: function(request, response) {
// delegate back to autocomplete, but extract the last term
response($.ui.autocomplete.filter(
availableTags, extractLast(request.term)));
},
focus: function() {
// prevent value inserted on focus
return false;
},
select: function(event, ui) {
var terms = split(this.value);
// remove the current input
terms.pop();
// add the selected item
terms.push(ui.item.value);
// add placeholder to get the comma-and-space at the end
terms.push("");
this.value = terms.join(", ");
return false;
}
});
});
あなたは空想を取得したい場合:https://jsfiddle.net/Twisty/hvLdp11j/6/ – Twisty
それとも、複数のインスタンスが必要な場合:https://jsfiddle.net/Twisty/hvLdp11j/9/ – Twisty
わかりません。調査しなければならないだろうか。あなたは容疑者にすることができます。 – Twisty