选择和选择2有什么区别? [英] What are the differences between Chosen and Select2?

查看:46
本文介绍了选择和选择2有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

选择 Select2 是两个最受欢迎的扩展选择框的库.

Chosen and Select2 are the two more popular libraries for extending selectboxes.

两者似乎都得到了积极的维护,而选择的年龄较大,并且同时支持jQuery和Prototype.

Both seem to be actively maintained, Chosen is older and supports both jQuery and Prototype.

Select2仅是jQuery,其文档说Select2受选择的启发,但没有详细说明所做的任何改进(如有)或其他重写原因.

Select2 is jQuery only, its documentation says Select2 is inspired by Chosen, but doesn't detail any improvements made (if any) or other reasons for the rewrite.

两个库具有几乎相同的功能集,我发现的唯一比较是一个不确定的jsperf测试页.

Two libraries have pretty much same feature set, the only comparison I've found is a somewhat inconclusive jsperf test page.

这些库中的任何一个都比其他库有什么优势吗?

Does any of these libraries have any advantages over the other?

推荐答案

从Select2 3.3.1开始,以下是其README.md中记录的内容

As of Select2 3.3.1, below are what's documented in its README.md

Select2支持哪些选择的内容?

What Does Select2 Support That Chosen Does Not?

  • 使用大型数据集:选择需要将整个数据集作为DOM中的option标记加载,这限制了它只能用于 小数据集. Select2使用一个函数来查找结果 快速运行,从而可以部分加载结果.
  • 分页:由于Select2可处理大型数据集,并且一次只能加载少量匹配结果 分页.当用户滚动到Select2时,它将调用搜索功能 当前加载结果集的底部,允许无穷大" 滚动".
  • 结果的自定义标记:选择的仅支持呈现文本结果,因为这是option标记支持的唯一标记. Select2提供了一个扩展点,可用于生成任何 一种表示结果的标记.
  • 即时添加结果的能力:Select2提供了从用户输入的搜索字词中添加结果的能力,这使其可以 用于标记.
  • Working with large datasets: Chosen requires the entire dataset to be loaded as option tags in the DOM, which limits it to working with small-ish datasets. Select2 uses a function to find results on-the-fly, which allows it to partially load results.
  • Paging of results: Since Select2 works with large datasets and only loads a small amount of matching results at a time it has to support paging. Select2 will call the search function when the user scrolls to the bottom of currently loaded result set allowing for the 'infinite scrolling' of results.
  • Custom markup for results: Chosen only supports rendering text results because that is the only markup supported by option tags. Select2 provides an extension point which can be used to produce any kind of markup to represent results.
  • Ability to add results on the fly: Select2 provides the ability to add results from the search term entered by the user, which allows it to be used for tagging.

这篇关于选择和选择2有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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