admin管理员组文章数量:1328584
I am using jQuery autoplete. Here is my
HTML
<input class="autoplete_input">
JS
$(".autoplete_input").autoplete({
source: autopleteOptions
});
// autopleteOptions is a array which contains all values for autoplete
Everything is working fine. I want to dispaly all suggestions on onFocus
. After some Googling and reading some similar questions on SO I found the minChars
property of Autoplete. I tried but still no luck
$(".autoplete_input").autoplete({
source: autopleteOptions,
minChars:0
});
How can I use minChars
correctly?
EDIT1:
I am using this link. Thank you Rory.
On given link I couldnt find minLength
property.
EDIT2:
I tried
$(".autoplete_input").autoplete({ minLength: 0, source: autopleteOptions});
Still suggestions are not displayed on onFocus
. One difference I noticed is if I type any char then corresponding results are displayed and if I delete that char using backslash then all suggestions are displayed.
I am using jQuery autoplete. Here is my
HTML
<input class="autoplete_input">
JS
$(".autoplete_input").autoplete({
source: autopleteOptions
});
// autopleteOptions is a array which contains all values for autoplete
Everything is working fine. I want to dispaly all suggestions on onFocus
. After some Googling and reading some similar questions on SO I found the minChars
property of Autoplete. I tried but still no luck
$(".autoplete_input").autoplete({
source: autopleteOptions,
minChars:0
});
How can I use minChars
correctly?
EDIT1:
I am using this link. Thank you Rory.
On given link I couldnt find minLength
property.
EDIT2:
I tried
$(".autoplete_input").autoplete({ minLength: 0, source: autopleteOptions});
Still suggestions are not displayed on onFocus
. One difference I noticed is if I type any char then corresponding results are displayed and if I delete that char using backslash then all suggestions are displayed.
6 Answers
Reset to default 4Are you using jQuery UI Autoplete?
The correct parameter would be minLength
$( ".selector" ).autoplete({ minLength: 0, source: autopleteOptions });
Assuming this is the plugin you're using, try this:
$(".autoplete_input").autoplete(
autopleteOptions,
{ minChars: 0 }
});
/* * jQuery Autoplete plugin 1.2.3 * * Copyright (c) 2009 Jörn Zaefferer * * Dual licensed under the MIT and GPL licenses: * http://www.opensource/licenses/mit-license.php * http://www.gnu/licenses/gpl.html * * With small modifications by Alfonso Gómez-Arzola. * See changelog for details. * */ in line 588 change this [[[ for (var i = q.length - 1; i >= options.minChars; i--) { ]]] for this [[[ for (var i = q.length - 1; i >= 0; i--) { ]]]
Try to use focus
event and call autoplete showing manually:
$(".autoplete_input").autoplete({
source: autopleteOptions
}).focus(
function() {
if (this.value == "") {
$(this).autoplete('search', '');
}
}
);
Here is the documentation page for jQuery autoplete: http://jqueryui./demos/autoplete/
The option you're looking for is minLength
$(".autoplete_input").autoplete({
source: autopleteOptions,
minLength:0
});
set minchars: 0; make below changes in your autoplete.js file.
Inside "window.opera" add a click event like shown below
this.el.click(function () {
e.onClick();
}),
and add this function after "onValueChange"
onClick: function () {
var ae = this.getQuery(this.currentValue);
if(ae.length < 1){
this.onValueChange();
}
},
look for "onValueChange" function and in there replace the return argument as shown below
//return (this.selectedIndex = -1), this.ignoreValueChange ? void (this.ignoreValueChange = !1) : void ("" === e || e.length < this.options.minChars ? this.hide() : this.getSuggestions(e));
return (this.selectedIndex = -1), this.ignoreValueChange ? void(this.ignoreValueChange = !1) : void (this.getSuggestions(e));
本文标签: javascriptAutocomplete minChars propertyStack Overflow
版权声明:本文标题:javascript - Autocomplete minChars property - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742257280a2441859.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论