开发者

jQuery event when autocomplete suggestions are displayed

I have an autocomplete with the source being a local array containing names. I want to know which of these names are being filtered by the autocomplete, and it seems to be more difficult than I thought! - The search event is not good to me since it is being fired before the filterin开发者_如何学Cg happens. - The open event is not good either since it happens only once. If the user keeps on typing then I don't have the filtered values.

So I don't see an option right now. I must say it feels completely weird to me. I would expect an easy way to grab these values, and hopefully there is. What am I missing here? Thanks


I would probably just use onKeyUp. That way you can check after every change to the auto-complete suggestions.


If you're not concerned about running the filter twice every time, you can still use the search callback.

$("#list").autocomplete({
    source: anArray,
    search: function(event){
        var data = $(event.target).data("autocomplete");
        var result = $.ui.autocomplete.filter(data.options.source, data.term);
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜