jQuery UI 自动完成 - 从字符串的开头搜索
我想将 Jquery UI 插件设置为仅从字符串的开头进行搜索。我发现一些类似的问题,但没有可用的答案。 我有这个代码:
$.ajax({
url: "{!$basePath}/mesta.xml",
dataType: "xml",
success: function( xmlResponse ) {
var data = $( "city", xmlResponse ).map(function() {
return {
value: $( "name", this ).text(),
id: $( "name", this ).text()
};
}).get();
$( ".autocomplete" ).autocomplete({
source: data,
minLength: 0
});
}
});
谢谢。
I want to set Jquery UI plugin to search only from the beginning of the string. I find some simillar questions but no usable answer.
I have this code:
$.ajax({
url: "{!$basePath}/mesta.xml",
dataType: "xml",
success: function( xmlResponse ) {
var data = $( "city", xmlResponse ).map(function() {
return {
value: $( "name", this ).text(),
id: $( "name", this ).text()
};
}).get();
$( ".autocomplete" ).autocomplete({
source: data,
minLength: 0
});
}
});
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将 @Samich 发布的链接中的内容应用到您的
source
选项即可:这是一个小提琴演示:http://jsfiddle.net/jensbits/PekQZ/
Just apply what is in the link @Samich posted to your
source
option:And here is a fiddle demo: http://jsfiddle.net/jensbits/PekQZ/