mysociety / jquery-multi-select

Converts <select multiple> elements into dropdown menus with checkboxes
https://www.mysociety.org/
Other
24 stars 18 forks source link

Trim whitespace from option .text() before concatenating into comma-separated button label #2

Closed zarino closed 8 years ago

zarino commented 8 years ago

If the <option> elements have leading or trailing whitespace inside them, this is preserved when the button text is constructed by updateButtonContents.

This could be unexpected, because the browser would normally strip this leading and trailing whitespace when displaying elements like that. We should do the same.

Should be simple enough to turn line 194 from:

selected.push( $(this).text() );

Into:

selected.push( $.trim($(this).text()) );