ivaynberg/select2 — pull request #2765 by straeger (2014-10-28 10:08:43+00:00)
Title:  Add function for generation of suffix id for single container.

Hello,

I have currently an issue with single container.
I need a possibility to customize the generation of the idSuffix for the generated ```

``` which the user interacts with.

In initContainer ( https://github.com/ivaynberg/select2/blob/master/select2.js#L2084 ) the function nextUid which uses the counter function ( https://github.com/ivaynberg/select2/blob/master/select2.js#L105 ) is used to generate the id for the replacement.

The Problem with the generated ID is that in our dynamic generated UI which gets UI Unit testet we can not be sure that it is always the same. So if the ID can not be found the unit test will fail.

My changes add the possibility to provide a function which takes the original element and uses the id to generate the suffix.

So a user can initialize select2 with an option idSuffixGenerator.
e.g.
```javascript
$('select').select2({
idSuffixGenerator :function(element) {
var id = element.attr('id');
return id.length != 0 ? id : new Date().getTime();
};
})
```

Please let me know what you think about it.

Regards Stephan