【发布时间】:2016-09-21 03:54:03
【问题描述】:
我有一个自动完成控件,当第一组自动完成的“建议”从我的自定义数据源呈现时,它就会起作用。
我有一种机制可以检测滚动何时位于最底部,在这种情况下会加载附加数据并将其附加到自动完成 UL 元素。
// This loads more data when scroll bar reaches the bottom of autocomplete suggestion list.
$(".autocomplete ul", $MyForm).bind('scroll', function () {
var $this = $(this);
if ($this.scrollTop() > maxScrollTopLength) {
maxScrollTopLength = $this.scrollTop();
if (!currentCallInProgress && maxScrollTopLength > $this[0].scrollHeight - $this.height() - settings.bottomScrollLength) {
skipToken += 1;
// search for suggestions based on scroll movement.
loadMoreItems(pageSearch.$query.val());
}
}
});
问题是这样的:
附加的项目是不可点击的,尽管它们出现在列表中。 我做错了什么?
请注意,在处理附加数据项加载的方法中,没有要调用的响应对象(它是为源:函数调用的)。
* 更新:*
我的自动完成控件实现源码:像这样:
source: function (request, callback) {
loadData(request.term, callback);
// loadData basically makes an $.ajax call to retrieve data, and calls -
// callback(results)
}
来源:函数(请求、响应){
【问题讨论】:
标签: jquery autocomplete jquery-ui-autocomplete