Search placeholer

I’m using the following code to create a Select2 select list:

<script>
  $( document ).ready( function() {
    $( '.js-example-placeholder-multiple' ).select2( {
       placeholder : 'Choose categories',
       closeOnSelect: false,
       tags: true,
       tokenSeparators: [ ',', ' ' ]
    } );
  } );
</script>
<select id="genreSelect" name="genreSelect"
               class="js-example-placeholder-multiple js-states form-control"
               multiple="multiple"
               style="height: 30px; display: block; position: absolute;"
               title="Select one or more categories, then
                        click the form to accept your selection(s).">
  <optgroup label="Alternative">
    <option value="Alternative_Rock">Alternative Rock</option>
    <option value="College_Rock">College Rock</option>
    <option value="Experimental_Rock">Experimental Rock</option>
    <option value="Goth/Gothic_Rock">Goth/Gothic Rock</option>
    <option value="Hard_Rock">Hard Rock</option>
  </optgroup>
  <option value="Other">Other</option>
</select>

Now I want to display “Choose more categories” as a place holder in the Results box when there are any selected items. Note, the “Choose categories” placeholder displays when there are no selected items, and I don’t want the Search placeholder to also be displayed in this case.

I don’t think what you’ve described is possible with the built-in capabilities (placeholders, tagging, multi-select) of the Select2 widget. Note that, for a multi-select Select2 widget, the placeholder text is never displayed in the Results box (the dropdown). In the Search box (the text field that displays the selected items) the placeholder is not displayed when any items are selected.

You might be able to do what you want by creating your own Placeholder decorator, or possibly a Tags decorator; but I have no experience creating decorators and there doesn’t seem to be much documentation about the topic. Your best bet would probably be to look at the default decorators, figure out how they work, and see if you can modify them to do what you want.

Good luck to you!