0
我有以下的jQuery:jQuery的滚动自动完成 - 检测底部
$("#input-name").autocomplete({
source: function(request, response) {
if (!names.length){
names = [NoResultsLabel];
}
response(names);
},
select: function (event, ui) {
if (ui.item.label === NoResultsLabel) {
event.preventDefault();
}
for(var i=0;i<data.schools.length;i++){
if(ui.item.label == names[i]){
document.getElementById('filter[id]').value = ids[i];
i = data.schools.length;
}
}
},
focus: function (event, ui) {
if (ui.item.label === NoResultsLabel) {
event.preventDefault();
}
}
});
我加入这个CSS,使其滚动:
<style>
.ui-autocomplete {
max-height: 100px;
overflow-y: auto;
overflow-x: hidden;
}
.ui-state-focus {
font-weight: normal;
}
</style>
,我想,当用户滚动至底部检测并发起一个Ajax请求,因为有太多的行匹配相同的名称(即时通过他们的名字搜索学校和选择即时通讯返回核心申请ID
我试过这个
jQuery(function($) {
$('.ui-autocomplete').on('scroll', function() {
if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) {
requests++;
getSchools();
}
})
});
,但它不工作