开发者

JQuery Autocomplete: Overriding default behavior

I want to have some sort of custom autocomplete and I thought it makes more sense to customize jQuery's autocomplete. So I'd like to know:

  1. How to force open the autocomplete list? $("#autocomplete").trigger('autoco开发者_如何学Cmpleteopen'); doesn't work.

  2. How to put your own stuff onto the list? Obviously not through source option, but from outside it.

In other terms, from 1 and 2, I want to have a list of all options (not limited by limit) and I want it open and showing all the options before the user starts to type and regardless of what the user is typing.

Any help would be appreciated.

Cheers

Parsa


The other answer didn't help me much (in regards to your question 1), however after a bit of digging around I have found the easiest way to force the autocomplete list to open. All you need to do is simply call the 'search' method.

The first thing you need to do is initilase your autocomplete with a minlength of 0, like so:

$('#autocomplete').autocomplete({
  minLength: 0,
  ...
});

Then you can call the search method to open the list:

$('#autocomplete').autocomplete('search');

Hopefully this helps other people searching for an answer to this problem.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜