harvesthq/chosen — pull request #692 by cjstewart88 (2012-06-20 18:52:37+00:00)
Title: Add functionality to allow templates

I've added the functionality to allow templates in dropdowns by using the `data` attribute on `options` and a `template` option when setting up chosen.

I've compiled the code and provided jquery and prototype examples.

Below is the jQuery example.

### DOM:

M&Ms

Starburst

Skittles

Reese's

Snickers

### Initialize It:

$(".chzn-select-template-example").chosen({
template: function (text, templateData) {
return [
"User Rating: " + templateData.userRating + "",
"

" + text + "

",
"

type of candy: " + templateData.type + "

"
].join("");
}
});

### Result:

![image](http://i.imgur.com/ba7sQ.png)

Thanks to Elliott Wood for code reviewing and to Select2 for inspiration.