开发者

jQuery autocomplete minLength

The autocomplete never fires on first character entered but 2nd. Although after using back-space it works for the minLength = 1. Also, the selectFirst:true never defaults to first item in the array on page load.

$().ready(function (){ 
       $('#CompanyName').autocompl开发者_开发问答ete({
                 source: companyNames,
                 select: SetLocations, 
                 selectFirst :true,
                 minLength: 0  //corrected as suggested, but still no change
      });
});

Has anybody faced this behavior before. I'm clueless since I haven't any global settings/defaults.


You have a few syntactical errors, the document.ready handler is missing a brace (and is deprecated anyway) and a comma in your options, it should look like this:

$(function() {
   $('#CompanyName').autocomplete({
             source: companyNames,
             select: SetLocations, 
             selectFirst: true, //here
             minLength: 0
  });
});

Also, autocomplete activates after minLength characters, if you want it immediately, use 0, from the docs:

minLength: The minimum number of characters a user has to type before the Autocomplete activates. Zero is useful for local data with just a few items. Should be increased when there are a lot of items, where a single character would match a few thousand items.

.....

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜