2

我正在使用http://jqueryui.com/demos/autocomplete/#default

我的数据

[{"icd_ID":"2","icd_code":"A00","icd_desc":"Cholera","icd_yn":"N"},
        {"icd_ID":"3","icd_code":"A00.0","icd_desc":"Cholera due to Vibrio cholerae 01, biovar cholere","icd_yn":"Y"},
        {"icd_ID":"4","icd_code":"A00.1","icd_desc":"Cholera due to Vibrio cholerae 01, biovar eltor","icd_yn":"Y"},
        {"icd_ID":"5","icd_code":"A00.9","icd_desc":"Cholera, unspecified","icd_yn":"Y"}
        ]

对于“icd_desc”自动建议值,我想获得“icd_code”。

jsfiddle 链接: http: //jsfiddle.net/ajaypatel_aj/P ​​Rnc9/

4

2 回答 2

2

如果您使用的是本地数据源,我会转换该数据源以符合小部件的预期:

var source = $.map(availableTags1, function (el) {
    return {
        label: el.icd_desc,
        value: el.icd_code
    };
 });

 $("#tags").autocomplete({
    source: source
 });

示例:http: //jsfiddle.net/sXaZX/

于 2012-06-26T13:50:08.770 回答
1

您是否使用服务器端脚本对此进行编码?当您请求页面时,本地数据在响应中吗?所以只需拆分 10 个项目

于 2012-06-27T06:56:11.973 回答