I am using below plugin to create autoplete feature:
below is their live demo:
now the problem is, I'd like to filter the result and only show letter match start with first letter.
for example, if I typed into 'a', only countries start with 'a' should appear.
I checked this plugin's library, I saw there is a lookupFilter
function there, but don't know how to use it.
would anyone who had used this library before kindly give some pointers?
I'd like to use this plugin instead of jQuery UI, as it is light weighted.
I am using below plugin to create autoplete feature:
https://github./devbridge/jQuery-Autoplete
below is their live demo:
http://www.devbridge./sourcery/ponents/jquery-autoplete/#jquery-autoplete
now the problem is, I'd like to filter the result and only show letter match start with first letter.
for example, if I typed into 'a', only countries start with 'a' should appear.
I checked this plugin's library, I saw there is a lookupFilter
function there, but don't know how to use it.
would anyone who had used this library before kindly give some pointers?
I'd like to use this plugin instead of jQuery UI, as it is light weighted.
Share Improve this question edited Apr 23, 2014 at 9:13 JavaScripter asked Apr 23, 2014 at 9:07 JavaScripterJavaScripter 4,85210 gold badges39 silver badges45 bronze badges 01 Answer
Reset to default 5I checked lookupFilter
in their library and below is the code:
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
},
Here they are returning the value bascially if it is present in the results.
-1
means the letter a
is not found, so they're returning the value at any occurrence.
So just tune it as:
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
return suggestion.value.toLowerCase().indexOf(queryLowerCase) === 0;
},
Exactly at 0th index.
This will return the results with a
as first occurance.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745398500a4625991.html
评论列表(0条)