jQuery UI自动完成:计算结果 [英] jquery ui autocomplete: count results

查看:92
本文介绍了jQuery UI自动完成:计算结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法可以计算在文本框中键入内容时显示的结果数.算一下锂元素的工作量,但我敢打赌,这是一种更聪明的方法.谢谢

i would like to know if theres a way to count the number of results which are displayed when you type something in the textbox. Count the li-elements work, but i bet theres a smarter way. Thanks

推荐答案

我认为直接使用JQueryUI事件是不可能的.我正在寻找没有成功的方法.

I think that this is not possible directly using JQueryUI Events. I've looking for a way without success.

所有关联的事件仅返回单击的元素(显示列表之后),或有关事件的信息(而不是列表).

All the events associated only return the element clicked (after the list is displayed), or information about the event (not about the list).

您可以在这里看到它: http://jqueryui.com/demos/autocomplete/#事件焦点

You can see it here: http://jqueryui.com/demos/autocomplete/#event-focus

您所说的是最接近的解决方案:

What you said is the most closely solution:

$( "#tags" ).autocomplete({
  source: availableTags,
  open: function(event,ui){
    var len = $('.ui-autocomplete > li').length;
    $('#count').html('Founded '+len+' results');
  }
});

这篇关于jQuery UI自动完成:计算结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆