如何在jQuery UI自动完成中设置至少两个字符?

我正在使用jQuery自动完成,并希望仅在用户键入至少2个字符时限制显示结果。 怎么做?

作为记录:

用户在激活自动填充之前必须输入的最小字符数。 零对于只有几个项目的本地数据很有用。 当有很多物品时,应该增加,其中一个角色可以匹配几千个物品。

代码示例

使用指定的minLength选项初始化自动完成。

 $( ".selector" ).autocomplete({ minLength: 0 }); 

在init之后获取或设置minLength选项。

 //getter var minLength = $( ".selector" ).autocomplete( "option", "minLength" ); //setter $( ".selector" ).autocomplete( "option", "minLength", 0 ); 

minLengthIntegerDefault:1

文档

 $( "#myselectbox" ).autocomplete({ minLength: 2 }); 

没有minLength属性。 您要搜索的属性是minChars

请参阅https://github.com/devbridge/jQuery-Autocomplete