javascript - JQuery Autocomplete Custom Lookup Function - Stack Overflow

I want to use jquery.autoplete.js plugin for an input in my form. I want to search on the client side a

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 badges
Add a ment  | 

1 Answer 1

Reset to default 6

It 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

相关推荐

  • javascript - JQuery Autocomplete Custom Lookup Function - Stack Overflow

    I want to use jquery.autoplete.js plugin for an input in my form. I want to search on the client side a

    1天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信