0
我已經搜索過了,但我很難讓它與我正在使用的代碼一起工作。自動完成結果中的jQuery UI粗體字
我希望我的輸入在自動完成結果中加粗,任何人都可以提供幫助嗎?由於
jQuery('#description-input:not(.ui-autocomplete-input)').live('focus', jQuery.proxy(function(event){
jQuery(event.target).trigger(this.config.events.AUTORESIZE).autocomplete({
source: jQuery.proxy(function(request, response) {
jQuery.ajax({
url: self.config.keyword_search_url,
dataType: "json",
data: { name_startsWith: request.q, q : jQuery('#description-input').val(),
level: this.selectedStore.getLevelId() },
select: function(event, ui) { event.stopPropagation(); },
success: function(data) {
response(jQuery.map(data, function(item) {
return { value: item };
}));
}
});
}, this),
focus : jQuery.proxy(function(event, ui) {
jQuery('body').undelegate('#description-input', 'blur');
jQuery('ul.ui-autocomplete').one('mouseleave', jQuery.proxy(function(event) {
jQuery('body').delegate('#description-input', 'blur', jQuery.proxy(function(event) {
self.exitEditItem(event);
}, this));
}, this));
}, this),
select : jQuery.proxy(function(event, ui) {
event.ui = ui;
self.editItemSpecialKeys(event);
jQuery('ul.ui-autocomplete').unbind('mouseleave');
jQuery('body').delegate('#description-input', 'blur', jQuery.proxy(function(event) {
self.exitEditItem(event);
}, this));
}, this),
position : {
my: 'center top',
at: 'center bottom',
offset: '0 -1px',
collision: 'flip'
},
delay: 0,
minLength: 2,
disabled: true
}).autocomplete('widget').addClass('autocomplete-list');
我曾嘗試使用這種方法:
function __highlight(s, t) {
var matcher = new RegExp("("+$.ui.autocomplete.escapeRegex(t)+")", "ig");
return s.replace(matcher, "$1");
}
但我沒有得到運氣。
等待ü需要改變jQuery UI的自動complite一些代碼,然後將它做工精細。我把代碼或鏈接放在這裏。 – Thulasiram
在juery用戶界面自動完成:_renderItem:功能(UL,項目){ \t \t回$( 「
」) \t \t \t。數據( 「item.autocomplete」,項目) \t \t \t .append($ (「」).text(item.label)) \t \t \t .appendTo(ul); \t},.append($( 「」)的.text(item.label))的 – Thulasiraminstend到.append($( 「」)。html的(item.label)) – Thulasiram