github地址:https://github.com/twitter/typeahead.js在aceAdmin界面模板中,有typeahead这一控件,版本号为0.10.2 , 这个版本对 minLength:0这个参数无效,所以我就到github中找到新版本0.11.1 替 ...
github地址:https://github.com/twitter/typeahead.js
在aceAdmin界面模板中,有typeahead这一控件,版本号为0.10.2 , 这个版本对 minLength:0这个参数无效,所以我就到github中找到新版本0.11.1 替换,在此记录使用过程中的一些注意事项
基本代码
var gameNameList = ['abc', 'abd', 'cde', 'xyz']; var gameNameMatcher = function(strs) { return function findMatches(q, cb) { var matches, substrRegex; // an array that will be populated with substring matches matches = []; // regex used to determine if a string contains the substring `q` substrRegex = new RegExp(q, 'i'); // iterate through the pool of strings and for any string that // contains the substring `q`, add it to the `matches` array $.each(strs, function(i, str) { if (substrRegex.test(str)) { matches.push({value:str}); } }); cb(matches); }; }; $('#Name').typeahead({ hint: true, highlight: true, minLength: 0 }, { name: 'gameNameList', displayKey: 'value', source: gameNameMatcher(gameNameList) });
原标题:typeahead.js 使用记录
关键词:JS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。