是否可以将一些 html 添加到 jquery 自动完成 ui 项?例如,我想将<strong></strong>
标签添加到自动完成结果 item label: item['name']
。我试过这样做label: '<strong>'+item['name']+'</strong>
,但它是作为文本应用的,而不是 HTML。
$('input[name="customer"]').catcomplete({
delay: 0,
source: function(request, response) {
$.ajax({
url: 'index.php?route=sale/customer/autocompletefilter_name=' + encodeURIComponent(request.term),
dataType: 'json',
success: function(json) {
response($.map(json, function(item) {
return {
category: item['customer_group'],
label: item['name'],
customer : item['name'],
value: item['customer_id'],
customer_group_id: item['customer_group_id'],
firstname: item['firstname'],
lastname: item['lastname'],
email: item['email'],
telephone: item['telephone'],
fax: item['fax'],
address: item['address']
}
}));
}
});
},
select: function(event, ui) {
//some actions on select
}
});
谢谢你。