我有一个具有自动完成 jQuery 字段的输入字段。
<input id="peopleRoleCodeAuto" type="text" size="50"/>
当我输入“A”时,我会看到列出的“ATPL”值。当我输入“AT”时它会消失,然后当我输入“ATP”时它会再次出现。我对 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
};
}
谢谢,
汤姆