r/javascript • • Jun 07 '13

Select2 - a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results

http://ivaynberg.github.io/select2/
69 Upvotes

11 comments sorted by

6

u/PolarZoe Jun 08 '13

I've been using Chosen, any reasons to switch to select2?

3

u/[deleted] Jun 08 '13

I had to switch from Chosen because it didn't support disabled options. When an option is marked as disabled, it is removed from the list, as opposed to being ghosted/greyed-out.

It's possible this has been fixed but the author never responded to the (fairly large) thread addressing the problem.

1

u/yeskia Jun 10 '13

I believe Select2 is a fork of Chosen which provides more features, retina support and others. We switched our projects a while ago.

2

u/exorcist72 Jun 08 '13

Although it displays fine on mobile, it's not really easy to use...

3

u/anarchy8 Jun 08 '13

On mobile browsers its usually better to trust the default select box anyway, since its more optimized.

2

u/minecraft_ece Jun 08 '13

But it doesn't scale to hundreds of items.

1

u/nschubach Jun 08 '13

I'm having a bitch of a time with it because when it opens the browser (FF Mobile) scrolls the window and it ends up below the keyboard. I'm sure it looks great on the desktop though. Also lots of "jiggyness" like it's rendering parts of it instead of all at once.

1

u/minecraft_ece Jun 08 '13

For now, my solution is to popup a modal dialog box with the select2 widget in it. The dialog box is pinned to the top half of the screen. That way I can keep it from being obscured by the keyboard.

1

u/clinisbut Jun 10 '13

I've been using it for a year or so, and while it works like a charm, I find its api quite disgusting:

  • The first one is that you must decide if you want to use a SELECT tag or an INPUT HIDDEN based on which options you want to use. Although author said that this is going to be fixed in version 4.0.

  • Some weird desitions about how some options work. For example, the worst one is data and tags properties. Both define values to populate the selector, but if you use tags you allow the user to create new values. I think this mode should be enabled through a boolean type property.

  • formatSelection does not escape html output, but formatResult does so you must implement an escapeMarkup.

There are some others I've found, but as I said, it works like a charm, only that I find quite difficult to configure it as I need for different projects.

1

u/[deleted] Jun 11 '13

It's pretty good, been using it for more than a year.

It took forever to figure out how to use the pagination api.

I created an Erlang standard library search website with it. Sadly parsing the Erlang doc is so time consuming that I gave up on the project.

0

u/[deleted] Jun 07 '13

Awesome! Great job there!