ivaynberg/select2 — pull request #2129 by campbell (2014-02-18 03:00:43+00:00)
Title: Bugfix - only selected options that are not disabled should be used when initializing a dropdown

If you disable a selected `option` via Javascript, then that option is not included in the `select` value. However, Select2 will not remove the selected & disabled option and it shows up in the list of selected values.

Javascript will only return `option` value(s) that are not disabled. However, the `prepareOpts` methods return a list of all `selected` options regardless of whether they are disabled. Thus when the Select2 dropdown is displayed, these disabled options are also included in the list of selected options.

```
$('#buddy_ids').val() // Get select value (multi-select enabled)
["12"]

$('#buddy_ids option:selected')
[
​Diet Coach​
​ ]

$('#buddy_ids option:selected').attr('disabled', true) // Disable the lone selected option
[
​Diet Coach​
​ ]

$('#buddy_ids option:selected') // Selected AND disabled....
[
​Diet Coach​
​ ]

$('#buddy_ids').val() // Verify that the selected & disabled option is not returned
[]

$('#buddy_ids').trigger('change') // Tell Select2 that the options have changed

$('#s2id_buddy_ids div') // The Select2 display includes the selected & disabled option
[

​Diet Coach​

​ ]

$('#s2id_buddy_ids .select2-choices div')
[

​Diet Coach​

​ ]

```

The `prepareOpts` methods should filter out disabled options when returning a list of selected options.