Skip to content

Instantly share code, notes, and snippets.

@onozaty
Created October 24, 2015 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onozaty/d055aac1b16ac234c738 to your computer and use it in GitHub Desktop.
Save onozaty/d055aac1b16ac234c738 to your computer and use it in GitHub Desktop.
suggest.jsで2文字以上の入力で補完を始めるサンプル
// 補完候補の配列作成
var list = ['Java', 'JavaScript', 'Perl', 'Ruby', 'PHP', 'Python', 'C', 'C++', '.NET', 'MySQL', 'Oracle', 'PostgreSQL'];
var startup = function(){
new Suggest.Local(
'text',
'suggest',
list,
{
getInputText: function() {
// 2文字以上の入力があった場合のみ補完処理実施
if (this.input.value.length >= 2) {
return this.input.value;
}
return '';
}
});
};
window.addEventListener
? window.addEventListener('load', startup, false)
: window.attachEvent('onload', startup);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment