更新时间:2023-11-21 17:41:34
您应该可以将其添加到autocomplete
调用的末尾:
You should be able to add it to the end of the autocomplete
call:
function Autocomplete(numberLocation,nameLocation,dscLocation,chargeLocation) {
$(fundNumberField).autocomplete ({
minLength: 4,
source: function(request, response){
var fundnum = $('#str-misc-FundNumber1').val();
fundnum = escape(fundnum);
var querystring = "?term=" + fundnum;
if (typeof (window.sortorder)=='undefined'){
querystring = querystring + '&sortorder=0';
} else {
querystring = querystring + '&sortorder=' + window.sortorder;
}
$.ajax({
url: 'ajax/fundid-autocomplete.php'+querystring,
beforeSend: function(){},
async: true,
dataType: "json",
success: response
});
},
focus: function ( event,ui ){
$(numberLocation).val( ui.item.value );
return false;
},
select: function( event, ui ) {
$(numberLocation).val( ui.item.value );
$(nameLocation).html( ui.item.desc );
if(ui.item.dsc >0) {
chargeLocation.hide();
dscLocation.show();
dscLocation.html('DSC Charge: '+ui.item.dsc+' %');
} else {
dscLocation.html('');
chargeLocation.show();
}
$('#numberlabel').html('Fund #*');
return false;
}
}).data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.value + " | " + item.desc + "</a>" )
.appendTo( ul );
};
}
当我通过JSLint运行该代码时,我实际上没有任何问题(我确实在source
函数中添加了一个缺少的分号).唯一缺少的是fundNumberField
定义(我假设是在其他地方定义的).
When I run that code through JSLint I don't really have any issues (I did add a missing semicolon inside the source
function). The only thing that's missing is the fundNumberField
definition (I'm assuming that's defined elsewhere).