以编程方式使输入[type = url]的datalist以JavaScript显示 [英] Programmatically make datalist of input[type=url] appear with JavaScript

查看:203
本文介绍了以编程方式使输入[type = url]的datalist以JavaScript显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Chrome中,至今只有在输入或双击输入元素时才会出现Datalist,例如, http://jsfiddle.net/r7Y4v/



我试图让数据显示更快出现。理想情况下,我会在输入旁边放置一个下拉箭头,点击时会使Datalist出现。



我正在寻找webkit解决方案。

解决方案

在规范中我找不到任何东西。



另外我注意到,在当前浏览器中的实现看起来有很大不同(点击vs dbl-click,箭头键,完整列表和过滤列表以及过滤器如何匹配部分输入等)。

对我来说,现在看起来仍然没有正常工作的组合框,并且数据列表似乎处于初期阶段。



所以看起来你现在会更好地推出自己的或者使用现成的库。

在我看来,''图书馆是相当流行(很好的链接读取)。

在该页面是一个链接到它的
GitHub代码演示页面



注意: 我很乐意有人给出更好的答案!我认为这是一个不错的主意,省去了箭头按钮,这样人们可以有更好的样式选择下拉按钮,如果他们想要一个可以连接到datalist /自动完成/组合框。我很惊讶所有这些似乎还没有明确说明,也没有得到本地支持。请特定作者给我们简单的本地组合框(过期已经很久了),然后添加像过滤器这样的香料!






编辑:自2012年8月起,Chromium项目中提供了一个打开的功能请求,要求提供下拉功能:


In Chrome and as for now the Datalist only appears when typing or double clicking on the input element, e.g. http://jsfiddle.net/r7Y4v/

I'm trying to make the datalist appear sooner. Ideally I would put a little "dropdown arrow" next to the input that when clicked would make the Datalist appear.

I'm looking for a webkit solution.

解决方案

I can't find anything in the specification how to do this.

Also I noticed that the implementation in current browsers seem to vary quite a bit (click vs dbl-click, arrow-key's, full versus filtered list and how filters match the partial input, etc).

To me, it seems that for now there is still no properly working combo-box and the data-list seems to be in it's infancy.

So it appears you'd currently be better of to roll your own or use a ready library.
It seems to me the 'minimul datalist' library is rather popular (good link to read to).
On that page is a link to it's GitHub code and a demo page.

Side-note: I'd love that some-one gives a better answer! Also, at first I thought it was a good idea to leave out the arrow-button so people could have better styling-options for a drop-down button if they wanted one that they could hook-up to the datalist/autocomplete/combobox. I'm surprised all this still seems unspecified and not natively supported. Please, spec-writers, give us the simple native combo-box (that is overdue for so long) and then add spice like filters!


Edit: There is an open Feature request since August 2012 on the Chromium project that asks for a drop-down functionality:

这篇关于以编程方式使输入[type = url]的datalist以JavaScript显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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