我有一个输入字段,其中包含一个自动完成的jQuery字段。
<input id="peopleRoleCodeAuto" type="text" size="50"/>
当我输入&#34; A&#34;我看到&#34; ATPL&#34;价值列出。当我输入&#34; AT&#34;它消失了,然后当我输入&#34; ATP&#34;它再次出现。我有限的jQuery曝光,并想知道是否有人有一些建议。
jQuery('#peopleRoleCodeAuto').icisAutocomplete({
source: roleCodes,
localJson: true,
mustMatch: true,
linkedFields: ['peopleRoleCode', 'peopleRoleCodeDescription'],
select: function(event, ui){
jQuery('#peopleRoleCode').val(ui.item.id);
jQuery('#peopleRoleCodeDescription').val(ui.item.desc);
},
change: function(event, ui){
jQuery('#peopleRoleCode').val(ui.item.id);
jQuery('#peopleRoleCodeDescription').val(ui.item.desc);
}
})
function icisAutocomplete(param, parentElem){
return {
source: param['source'],
select: param['select'],
search: param['search'],
response: param['response'],
focus: param['focus'],
success: param['success'],
change: function (event, ui) {
if(jQuery(this).val() == ''){
jQuery(param['clear']);
}
if(param['mustMatch'] && ui.item == null){
jQuery(this).val('');
if(param['linkedFields']){
clearFields(param['linkedFields']);
}
} else{
if(param['change']){
jQuery(param['change'](event, ui));
}
}
if(param['fieldsToResetOnChange']){
clearFields(param['fieldsToResetOnChange']);
}
},
minLength: (param['allOpt'] ? 0 : (!jQuery.isNaN(param['minLength']) ? param['minLength'] : 1)),
allOpt: (param['allOpt'] ? true : false),
delay: 0,
autoFocus: true
};
}
谢谢,
汤姆
答案 0 :(得分:0)
一旦我们将以下代码searchOn:“id”添加到我们的jQuery代码
,这就开始工作了jQuery('#peopleRoleCodeAuto').icisAutocomplete({
source: roleCodes,
localJson: true,
mustMatch: true,
linkedFields: ['peopleRoleCode', 'peopleRoleCodeDescription'],
searchOn: "id",
select: function(event, ui){
jQuery('#peopleRoleCode').val(ui.item.id);
jQuery('#peopleRoleCodeDescription').val(ui.item.desc);
return false;
},
change: function(event, ui){
jQuery('#peopleRoleCode').val(ui.item.id);
jQuery('#peopleRoleCodeDescription').val(ui.item.desc);
return false;
}
})