harvesthq/chosen — pull request #988 by noahsark769 (2013-01-17 21:51:49+00:00)
Title: Add functionality for search templating

Add an option for a function to apply to a the term being searched for immediately before searching the option list (or whatever kind of list). This allows developers to receive what the user searches for and manipulate it as needed.

For example, a user could search for `USA` but chosen would be able to return results that contain `United States of America`.

### Implementation
```html

United States of America - Alabama

United States of America - Alaska

...

Canada - Ontario

```
```javascript
var template = function (term) {
if (term.indexOf('USA') !== -1) {
return term.replace('USA', 'United States of America');
} else if (term.indexOf('CA', 'Canada') {
return term.replace('CA', 'Canada');
}
return term;
};

$('.chosen').chosen({
'search_template': template
});
```
This simple example would allow users to see `United States of America - Alaska` when searching for `USA - Alaska`, etc.

Implemented in both jQuery and Prototype versions.