나는이 작업을 한동안하고 있으며 아무데도 갈 수없는 것처럼 보입니다. 기본적으로 나는 클래스에 의한 많은 입력에 대해 자동 완성을 가지고 있지만, 아약스를 게시하기위한 객체를 만들기 위해 특정 입력 ID를 가져야한다. (나는이 프로젝트를 위해 POST를 사용해야한다.)클래스에 jQuery 자동 완성, ID를 얻는 방법
$(".input_autocomplete").autocomplete({
source: function(request, response) {
// here is where I get the hash from local storage,
// reference the id and build the object
// tried this.id, $(this).prop('id'), no luck
$.ajax({
url: '/somepath/filename.htm',
contentType: 'application/json',
dataType: 'json',
type: 'POST',
data: JSON.stringify(obj),
success: function(json) {
return {
label: item.label,
value: item.label
}
},
error: function() {
// error handling
}
}); // ajax
} // source
});
나는, jQuery를에 아주 새로운 해요하지만 당신은 ATTR를 사용하여 시도해야 ('id') 대신 .prop ('id') 대신? 아는 한 이드는 소품이 아니라 attr입니다 ... 또한 점 구문을 사용하기 때문에 $ (this)가 jQuery 객체를 대상으로하고 있기 때문에 이동해야합니다. 희망이 문제를 해결합니다. – rafaelbiten