현재 코드는 jQuery 1.7.x를 사용하고 있습니다. jQuery 1.8로 업그레이드하고 싶지만 내 자동 완성 기능에 문제가있다. 동일한 코드로 2 개의 jsfiddles를 만들었습니다. 한 예에서는 올바르게 작동하지만 다른 예로는 제대로 작동하지 않습니다. 주된 문제는 검색하고 클릭 할 때 경고 상자에 무엇이 클릭되었는지 말하고 말해야한다는 것입니다. 이전 jQuery에서는 작동하지만 1.8에서는 작동하지 않습니다.jQuery 1.8 범주 완성 자동 완성
$.widget("custom.catcomplete", $.ui.autocomplete, {
_renderMenu: function(ul, items) {
var self = this,
currentCategory = "";
$.each(items, function(index, item) {
if (item.category != currentCategory) {
ul.append("<li class='ui-autocomplete-category search-dropdown-category'>" + item.category + "</li>");
currentCategory = item.category;
}
self._renderItem(ul, item);
});
}
});
$(document).ready(function() {
var data = [
{
label: "anders",
category: "aa"},
{
label: "andreas",
category: "aa"},
{
label: "antal",
category: "aa"},
{
label: "annhhx10",
category: "Products"},
{
label: "annk K12",
category: "Products"},
{
label: "annttop C13",
category: "Products"},
{
label: "anders andersson",
category: "People"},
{
label: "andreas andersson",
category: "People"},
{
label: "andreas johnson",
category: "People"}
];
$("#search_input").catcomplete({
source: data,
select: function(event, ui) {
alert(ui.item.label);
}
});
});
누구든지 거래가 무엇인지 알고 : http://jsfiddle.net/TPWXh/3/ 여기
코드입니다 - 여기 http://jsfiddle.net/u2GEe/1/
깨진, 1.8 버전입니다 - 여기
는 작업, 1.7 버전은 무엇입니까?
"item : undefined";/ – Stefan