Created
October 24, 2015 17:46
-
-
Save onozaty/d055aac1b16ac234c738 to your computer and use it in GitHub Desktop.
suggest.jsで2文字以上の入力で補完を始めるサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 補完候補の配列作成 | |
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