| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 | <section>  <div class="page-header">    <h1 id="dropdown">Dropdown</h1>  </div>  <p>    Select2 allows you to change the way that the dropdown works, allowing you    to do anything from attach it to a different location in the document or    add a search box.  </p>  <h2 id="dropdownParent">    Attached to body  </h2>  <p>    By default, Select2 will attach the dropdown to the end of the body and    will absolutely position it to appear below the selection container.  </p>  <div class="row">    <div class="col-sm-6">      <dl class="dl-horizontal">        <dt>Key</dt>        <dd><code>dropdownParent</code></dd>        <dt>Value</dt>        <dd>jQuery element or DOM node</dd>        <hr />        <dt>Adapter</dt>        <dd>          <code title="select2/dropdown">DropdownAdapter</code>        </dd>        <dt>Decorator</dt>        <dd>          <code title="select2/dropdown/attachBody">AttachBody</code>        </dd>      </dl>    </div>    <div class="col-sm-6">      <div class="alert alert-warning">        <strong>Heads up!</strong>        This will cause DOM events to be raised outside of the standard        Select2 DOM container. This can cause issues with        third-party components such as modals.      </div>    </div>  </div>  <p>    When the dropdown is attached to the body, you are not limited to just    displaying the dropdown below the container. Select2 will display above    the container if there is not enough space below the container, but there    is enough space above it. You are also not limited to displaying the    dropdown within the parent container, which means Select2 will render    correctly inside of modals and other small containers.  </p>  <h2 id="dropdown-attachContainer">    Attached below the container  </h2>  <p>    Select2 can place the dropdown directly after the selection container, so    it will appear in the same location within the DOM as the rest of Select2.  </p>  <div class="row">    <div class="col-sm-6">      <dl class="dl-horizontal">        <dt>Adapter</dt>        <dd>          <code title="select2/dropdown">DropdownAdapter</code>        </dd>        <dt>Decorator</dt>        <dd>          <code title="select2/dropdown/attachContainer">AttachContainer</code>        </dd>      </dl>    </div>    <div class="col-sm-6">      <div class="alert alert-warning">        <strong>Check your build.</strong> This module is only included in the        <a href="index.html#builds-full" class="alert-link">full builds</a> of        Select2.      </div>    </div>  </div>  <div class="alert alert-info">    <strong>      <a href="https://harvesthq.github.io/chosen/">Harvest Chosen</a>      migrators!    </strong>    If you are migrating to Select2 from Chosen, this option will cause    Select2 to position the dropdown in a similar way.  </div>  <h2 id="dropdown-search">    Search  </h2>  <p>    Users can filter down the results by typing a search term into a box that    is displayed at the top of the dropdown.  </p>  <dl class="dl-horizontal">    <dt>Adapter</dt>    <dd>      <code title="select2/dropdown">DropdownAdapter</code>    </dd>    <dt>Decorator</dt>    <dd>      <code title="select2/dropdown/search">DropdownSearch</code>    </dd>  </dl>  <p>    A search box is added to the top of the dropdown automatically for select    boxes where only a single option can be selected.  </p>  <h3 id="dropdown-minimumInputLength">    Minimum search term length to filter results  </h3>  <p>    Sometimes when working with large data sets, it is more efficient to start    filtering the results when the search term is a certain length. This is    very common when working with remote data sets, as allows for only    significant search terms to be used.  </p>  <div class="row">    <div class="col-sm-6">      <dl class="dl-horizontal">        <dt>Key</dt>        <dd><code>minimumInputLength</code></dd>        <dt>Value</dt>        <dd>integer</dd>      </dl>    </div>    <div class="col-sm-6">      <dl class="dl-horizontal">        <dt>Adapter</dt>        <dd>          <code title="select2/data/base">DataAdapter</code>        </dd>        <dt>Decorator</dt>        <dd>          <code title="select2/data/minimumInputLength">MinimumInputLength</code>        </dd>      </dl>    </div>  </div>  <h3 id="dropdown-maximumInputLength">    Maximum search term length to filter results  </h3>  <p>    In some cases, search terms need to be limited to a certain range. Select2    allows you to limit the length of the search term such that it does not    exceed a certain length.  </p>  <div class="row">    <div class="col-sm-6">      <dl class="dl-horizontal">        <dt>Key</dt>        <dd><code>maximumInputLength</code></dd>        <dt>Value</dt>        <dd>integer</dd>      </dl>    </div>    <div class="col-sm-6">      <dl class="dl-horizontal">        <dt>Adapter</dt>        <dd>          <code title="select2/data/base">DataAdapter</code>        </dd>        <dt>Decorator</dt>        <dd>          <code title="select2/data/maximumInputLength">MaximumInputLength</code>        </dd>      </dl>    </div>  </div>  <h3 id="dropdown-maximumInputLength">    Minimum results to display the search box  </h3>  <p>    When working with smaller data sets, the search box can take up more space    that is necessary, as there are not enough results for filtering to be    effective. Select2 allows you to only display the search box when the    number of search results reaches a certain threshold.  </p>  <div class="row">    <div class="col-sm-6">      <dl class="dl-horizontal">        <dt>Key</dt>        <dd><code>minimumResultsForSearch</code></dd>        <dt>Value</dt>        <dd>integer</dd>      </dl>    </div>    <div class="col-sm-6">      <dl class="dl-horizontal">        <dt>Adapter</dt>        <dd>          <code title="select2/dropdown">DropdownAdapter</code>        </dd>        <dt>Decorator</dt>        <dd>          <code title="select2/dropdown/minimumResultsForSearch">MinimumResultsForSearch</code>        </dd>      </dl>    </div>  </div>  <h2 id="dropdown-select-on-close">    Select the highlighted option on close  </h2>  <p>    When users close the dropdown, the last highlighted option can be    automatically selected. This is commonly used in combination with    <a href="#tags">tagging</a> and <a href="#placeholder">placeholders</a>    and other situations where the user is required to select an option, or    they need to be able to quickly select multiple options.  </p>  <dl class="dl-horizontal">    <dt>Adapter</dt>    <dd>      <code title="select2/results">ResultsAdapter</code>    </dd>    <dt>Decorator</dt>    <dd>      <code title="select2/dropdown/selectOnClose">SelectOnClose</code>    </dd>  </dl>  <h2 id="closeOnSelect">    Close the dropdown when a result is selected  </h2>  <p>    Select2 will automatically close the dropdown when an element is selected,    similar to what is done with a normal select box.  This behavior can be    changed though to keep the dropdown open when results are selected,    allowing for multiple options to be selected quickly.  </p>  <div class="row">    <div class="col-sm-6">      <dl class="dl-horizontal">        <dt>Key</dt>        <dd><code>closeOnSelect</code></dd>        <dt>Default</dt>        <dd><code>true</code></dd>      </dl>    </div>    <div class="col-sm-6">      <dl class="dl-horizontal">        <dt>Adapter</dt>        <dd>          <code title="select2/dropdown">DropdownAdapter</code>        </dd>        <dt>Decorator</dt>        <dd>          <code title="select2/dropdown/closeOnSelect">CloseOnSelect</code>        </dd>      </dl>    </div>  </div>  <p>    If this decorator is not used (or <code>closeOnSelect</code> is set to    <code>false</code>), the dropdown will not automatically close when a    result is selected.  The dropdown will also never close if the    <kbd>ctrl</kbd> key is held down when the result is selected.  </p></section>
 |