harvesthq/chosen — pull request #592 by dingram (2012-04-25 10:26:27+00:00)
Title: Implement handling of options that are both disabled AND selected

Allows Chosen to deal with items that are both disabled and selected (i.e. should show as selected but should not be deselectable). See also #516 and #586.

These changes include:

- Different class/styling on the disabled item
- Removal of the "x" link on the disabled item
- Tweaks to backspace-handling, to ignore disabled items
- An inadvertent fix for the Prototype code (see below)
- Update to the example files

This change does **not** update the compiled files, as I appear to have a different version of coffeescript (or different options), and didn't want to create needless changeset noise. This can be updated, however.

#### Prototype fix

I noticed that in `keydown_backstroke` (around line 490), it was calling:

@pending_backstroke = @search_container.siblings("li.search-choice").last()

but Prototype does not accept a selector argument to `siblings()`, so this was doing nothing. In order to replicate the functionality from jQuery, it would have to be something like:

@pending_backstroke = @search_container.siblings().accept( (x) -> x.x.hasClassName("search-choice") ).last()

with an additional tag name check. In any event, I updated the code to use:

@pending_backstroke = @search_container.siblings().reject( (x) -> x.hasClassName("search-choice-disabled") ).last()

as I needed to exclude disabled items, and it appeared to be doing the right thing anyway.