如何将远程源与jQuery UI组合框一起使用? [英] How to use remote source with jquery ui combobox?
问题描述
有 combobox 启用了自动完成功能.如何将JSON数据作为此组合框的源?
There is combobox with autocomplete enabled. How to pass JSON data as source for this combobox?
更新.我找到了部分答案替换为远程源).但是我不能选择值-看起来下面的代码有问题(它允许从选择选项中选择值(我没有).
Upd. I've found partial answer here - it allows me to use remote data source (original var input = this.input = $( "<input>" ).autocomplete({ source
is replaced with remote source). But I can not choose the value - looks like the problem is with the following code (it allows to choose values from the select options (which I don't have).
select: function( event, ui ) {
ui.item.option.selected = true;
self._trigger( "selected", event, {
item: ui.item.option
});
},
该如何解决?
此处是演示.
推荐答案
以下是工作示例- http ://jsfiddle.net/and7ey/TFerw/3/
如果请求为空term
,则远端应返回一些值(最受欢迎)-当用户按下组合框按钮时会发生这种情况.
Remote end should return some values (most popular) in case when empty term
is requested - it happens when user presses combobox button.
这篇关于如何将远程源与jQuery UI组合框一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!