Make Better Select Boxes with Chosen
harvesthq.github.com
harvesthq.github.com
(Tried to submit it as a story the other day but zero upvotes.)
edit:ops had this in my tab opened since morning and commented without refreshing
Looks like it would be very nice on a desktop though!
$(".recipient_relation").chosen disable_search_threshold: 10
And if in Backbone you'd like to have it preselect the value, run something like this after render (so you don't have to add much logic to your handlebar template for the markup):@$("#address_country_field option").each -> $(@).attr "selected", "selected" if self.model.get("address_country") is $(@).val()
It'd be nice to see some folks share their menu styles. The gradient on the select doesn't quite fit in with all site styles.
.chzn-container .chzn-results .highlightedIn Firebug, you can ask the :hover state to stay active.
1. HTML tab
2. Click on the element
3. Style menu on the right panel
4. choose :hover
It tricks the browser into thinking the mouse is really over the element (i.e., it doesn't just add :hover), so if you have a hover class added via JS that should work too.(Apparently this feature has been there for a long time, but I only found it recently. Changed my Firebug life.)
I tend to do a lot of setup on render of fields that are hidden and displayed later in the same view, but chosen throws an error on 'searchfield[0]'.
Also worthwhile checking out https://github.com/meltingice/ajax-chosen, which adds much-needed Ajax support to Chosen.js.
Chosen helped us overcome a fairly major multi-browser issue where embedded fonts weren't being used inside <select> elements (oddly it seemed to work in IE6 but not IE7). Since Chosen transmutes the <option>s into style-able divs, this allowed us to use our @font-face fonts with very few issues. We ended up using it across the site for consistency (with a few exceptions) and all in all I think it provided a usability improvement for most of our users.
> Instead of forcing your users to scroll through a giant list of items, they can just start typing the name of the item they were looking for.
Who's forcing? Modern browsers allow a user to type (in lowercase) text to find in a select element while focused and will scroll to an exact match inside of it. It would require some instructions, but deviations of that behavior have been around for a while.
> Because chosen replaces normal html select fields, you don't need to do anything special to make it work for browsers without JavaScript.
One definitely needs to do "something special" to make them work. Limiting options to massively bloated libraries like jQuery and Prototype is a big problem, especially for graceful degradation (impossible with both).
I'd be interested in something that works without a DOM library (definitely not impossible). Support beyond IE 8 would be a great idea as well.
That being said, I agree that this would be better off without jQuery; when every millisecond, every kilobyte matters, jQuery is simply off the table.
Perspective: My company has a jQuery/jQueryUI single-page web app (with MVC underpinnings) which serves a number of commercial customers very successfully. Does it matter that the whole app (which includes this plugin) may take 2-10 seconds to load from a cold-cache? No. After that there is absolutely zero load time throughout the entire app.
Btw, we also don't care about oldIE because we can insist commercial customers install Chrome-frame, which they are generally happy to do. They'd much rather that than we push a new 'native' desktop app at them and require them to install a .NET or Java runtime.
I wish people moaning about bloat and browser-support would actually think about the developers out there building products for very really use-cases that don't match their own mythical high-expectations of 'zero footprint/works-everywhere'. Some of us just want to get work done for paying clients and plugins like this are absolute life-savers.
Additionally they always highlight item that begins with typed letter. Because of that in default combobox i can type only "po" to get Poland, whereas search after typing "po" highlights French Polynesia. I think that difference is worth noting because it may searchbox more or less useful depending on data.
http://www.exratione.com/2011/12/a-dark-style-for-chosen-sel...
Way too much CSS, but I guess that's par for the course considering how much is going on inside the thing.
The thing is, when I see an OS-native-looking element I know immediately what it is.
For the skinned stuff, while it looks nice to the eye, it takes longer. When we're browsing thousand of pages a day it's kind of something you notice.
Overall, I'd recommend it if your needs are simple, but you might be better off rolling your own or using another library if you need anything advanced.
Anyway, great utility, extremely useful and could well be the way native drop downs should work.
No Opera?
it allows you to check wether your password is among the leaked ones.
The only thing I find missing is that, with the keyboard on a multiple select box, I can't remove my 1st choice without having to remove my 2nd choice too. (So, for instance if I choose Polar Bear and also choose Brown Bear, I try to move my cursor between them in order to Backspace over Polar Bear but I can't. I have to Backspace over Brown Bear + Polar Bear in order to delete Polar Bear.) It would be nice if, when I used my direction keys, it would highlight the selected items individually and then let me hit Delete or Backspace on my keyboard to delete just that one.
If you are looking for ideas, it would be really cool to see an improved scrolling of some kind. Still feels 1.0 with the ugly blue scrollbar.
Something like this but with softer colors: