mjon_git/src/main/webapp/js/recent_search.js
2023-06-12 11:15:02 +09:00

55 lines
2.1 KiB
JavaScript

$(document).ready(function(){
if($(".recentSearch").length > 100){ //임시막음
$(".recentSearch").autocomplete({ //오토 컴플릿트 시작
source : function(request, response){
$.ajax({
type: 'get',
url: "/uat/uia/RecentSearchShowAjax.do",
dataType: "json",
success: function(data) {
//서버에서 json 데이터 response 후 목록에 추가
response(
$.map(data, function(item) { //json[i] 번째 에 있는게 item 임.
return {
label: item, //UI 에서 보여지는 글자, 실제 검색어랑 비교 대상
value: item, //그냥 사용자 설정값?
test : item //이런식으로 사용
}
})
);
}
});
},
select : function(event, ui) { //아이템 선택시
console.log(ui.item);
},
focus : function(event, ui) { //포커스 가면
return false;//한글 에러 잡기용도로 사용됨
},
minLength: 1,// 최소 글자수
autoFocus: true, //첫번째 항목 자동 포커스 기본값 false
classes: { //잘 모르겠음
"ui-autocomplete": "highlight"
},
delay: 500, //검색창에 글자 써지고 나서 autocomplete 창 뜰 때 까지 딜레이 시간(ms)
position: { my : "right top", at: "right bottom" }, //잘 모르겠음
close : function(event){ //자동완성창 닫아질때 호출
console.log(event);
}
});
}
});
function updateRecentSearch(){
/*$.ajax({
url :"/uat/uia/RecentSearchUpdateAjax.do"
,type:"post"
,data:{"searchWord": $('.recentSearch').val()}
,dataType:"json"
,success:function(data){
}
,error: function(){
}
});*/
}