jQuery 自动完成与延迟加载
iOS API 有一个漂亮的功能,允许开发人员在用户向下滚动时在 UITableView
中延迟加载数据(与 UISearchBar
一起使用,可用作自动完成)。使用 jQuery 可以实现类似的自动完成功能吗?这样,当用户查询字母“a”时,建议应该填充前 x 个可见结果,当用户向下滚动时,视图将填充下 x 个结果?
PS:我尝试将 scroll
事件附加到 jQuery UI 自动完成的结果容器上,但我无法将滚动量映射到结果数。
iOS API has a beautiful feature which allows a developer to load data lazily in a UITableView
(which used along with UISearchBar
, can be used as autocomplete) when a user scrolls down. Can something similar be achieved with jQuery for autocomplete? Such that when user makes a query for say letter "a", the suggestions should be populated with first x number visible results and when the user scrolls down, the view is populated with next x results?
PS : I tried attaching the scroll
event on the results container of jQuery UI autocomplete, but I couldn't map the amount of scroll to number of results.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
jQuery 自动完成没有内置选项来执行此操作,因此您必须进行一些插件修改才能使其正常工作。例如,您可以检查最后一项是否可见,以确定是否加载下一组数据。
或者,您可以尝试像 Flexbox 这样的插件,它可能更适合您想要做的事情。 Flexbox 具有内置分页功能。
jQuery autocomplete has no built in options for doing this, so you'd have to do some plugin hacking to get it working. You might for example check whether the last item is visible to determine whether to load the next set of data.
Alternatively, you could try a plugin like Flexbox which might be more amenable to what you're trying to do. Flexbox comes with a built in paging feature.