I want to use jquery.autoplete.js plugin for an input in my form. I want to search on the client side and can't use ajax. But I don't want some simple "Contains"-based search algorithm within an array. What I want to do is to write a custom search function in javascript to search and order the results. Is this even possible and how?
Thanks for your time.
I want to use jquery.autoplete.js plugin for an input in my form. I want to search on the client side and can't use ajax. But I don't want some simple "Contains"-based search algorithm within an array. What I want to do is to write a custom search function in javascript to search and order the results. Is this even possible and how?
Thanks for your time.
Share Improve this question asked Sep 14, 2013 at 6:25 HoseinHosein 5811 gold badge7 silver badges29 bronze badges1 Answer
Reset to default 6It surely is. You specify source
to be a function which will answer a list of strings or alternatively {label, value}
objects.
$('#myInput').autoplete({
source: function (request, response) {
var term = request.term;
var data = handleAutoplete( term); /* get answers from somewhere.. */
response( data);
}
});
function handleAutoplete (term) {
var options = ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"];
// use 'term' for custom filtering etc.
return options;
}
See: http://api.jqueryui./autoplete/#option-source
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744955743a4603181.html
评论列表(0条)