silviomoreto/bootstrap-select — pull request #77 by mattbryson (2013-03-01 13:25:33+00:00)
Title: Added support for multi-select, default title, ticks to indicate selection, arrow in menu

Hey Silvio,

I have added support for Multi-select to your plugin, however, as you can imainge it required quite a hefty refactor - so im not sure how well it will merge, if at all you want to merge it, however, this is what is supported in this fork:

**New Classes**
The class `show-tick` on a `select` element will show a tick icon on the selected row(s).

The class `show-menu-arrow` on a `select` will add the small top arrow on the drop down menu.

**Attributes**
The attribute `multiple='multiple'` on the `select` will enable multiple selection within the drop down, and enable ticks icons by default.

The attribute `title='My Default test'` on the `select` will set the initial prompt text for the main button if no value has been set yet.

**js Properties**
The property `selectedText` in the JS constructor will set how the selected text is displayed. Values are:
1. `value` - will show the selected value, or comma delimited values if multiple select.
2. `count` - will show 'x of x Selected' if multiple selecte.
3. `count>n` - will show the 'x of x Selected' text only when more then `n` have actually been selected. Eg values if the `selectedText` is 'count>2', and the selected values are 'One', and 'Two' then the selected text is 'One,Two'. Once there are more than 2 selected, it will say something like '3 of 4 Selected' .
```javascript
$(".selectpicker.one").selectpicker({ selectedText:'count' });
$(".selectpicker.two").selectpicker({ selectedText:'count>4' });
```
**js Methods**
The method `val` has been exposed as part of the plugin, which will update the `select` value, and trigger a render of the plugin at the same time (this is because the jquery .val() does not trigger onChange.

```javascript
$(".selectpicker").selectpicker("val", "Two");
```

I also exposed the new `render` method, that allows the dev to still manually modify the `select`, and then call `render` themselves when done:

```javascript
$(".selectpicker").val("Two");
$(".selectpicker").selectpicker("render");
```

**Refactor**
To enable easy updating of the component, and easier branching of logic depending on multi select / single select, I refactored the creation and reload methods into one main method that creates the child Lis, which is called both by the `create` method and the `reload` method now.

This ment reworking the templates slightly, and adding elements via JQ rather than string replace of the template.

I then created a `render` method that simply updates the state of the LI list based on the state of the `select` element.

**Basic Demo HTML**
You can run this to test it out :

```html

default

One

Two

Three

With arrow in menu

One

Two

Three

With tick

One

Two

Three

Multiple

One

Two

Three

Default text

One

Two

Three

Selected text as count

One

Two

Three

Selected text as count above 2

One

Two

Three

```