adamcoulombe/jquery.customSelect — pull request #62 by RattleSneek (2013-11-04 10:59:44+00:00)
Title: customSelect with caption inside the select

Hi Adam,

I would like the possibility to have an empty option with no value, but still be able to provide a caption for the select, within the select itself. For instance, I would like the word 'Country' inside the select, but I don't want the first option of the select containing that word. I think that would be confusing for the end user.

With my proposed change, calling '$(selector).customSelect({getCaption: [func]})' the custom select will call that [func] function to get its caption and use that instead of the ' ' character for the empty option. On line 77 I create a new option with the caption for the control, before measuring the width, solely to get the right width for the 'span' elements. After the measurement I remove it again (line 83). In line 34 through 39, I add or remove the 'caption' class, to make it possible to style the selects differently when nothing was selected yet.

I hope you will consider my changes for release. Feel free to change my code in any way (Maybe it's already possible?).

I'd love to hear from you,

Erwin Keuning
Netherlands