1
0
mirror of synced 2024-11-22 21:16:10 +03:00

Fix indention, consistently declare anchor-nav relevant IDs for <h1> (instead of <section>).

This commit is contained in:
Florian Kissling 2015-05-08 03:41:52 +02:00
parent dc679f7cbd
commit 922d54615f
5 changed files with 1160 additions and 1161 deletions

View File

@ -1,30 +1,30 @@
<section id="adapters"> <section>
<div class="page-header"> <div class="page-header">
<h1>Adapters</h1> <h1 id="adapters">Adapters</h1>
</div> </div>
<p> <p>
Select2 allows plugins to add additional functionality through the core Select2 allows plugins to add additional functionality through the core
adapters. You can change almost anything involving the way Select2 works adapters. You can change almost anything involving the way Select2 works
to the way Select2 interacts with the page by modifying the core adapters. to the way Select2 interacts with the page by modifying the core adapters.
Most third-party plugins should provide decorators (used to wrap adapters) Most third-party plugins should provide decorators (used to wrap adapters)
and custom adapters that you can use. and custom adapters that you can use.
</p> </p>
<p> <p>
Each adapter contains a set of methods which will must always be defined. Each adapter contains a set of methods which will must always be defined.
Along with the global methods that all adapters must implement, these Along with the global methods that all adapters must implement, these
methods must be implemented. methods must be implemented.
</p> </p>
<h2 id="adapters-all"> <h2 id="adapters-all">
All adapters All adapters
</h2> </h2>
<p> <p>
All adapters must implement a set of methods that Select2 will use to All adapters must implement a set of methods that Select2 will use to
display them and bind any internal events. display them and bind any internal events.
</p> </p>
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
// The basic HTML that should be rendered by Select2. A jQuery or DOM element // The basic HTML that should be rendered by Select2. A jQuery or DOM element
@ -66,34 +66,34 @@ Adapter.position = function ($rendered, $defaultContainer) { };
Adapter.destroy = function () { }; Adapter.destroy = function () { };
</pre> </pre>
<h2 id="selectionAdapter"> <h2 id="selectionAdapter">
Container (selection) Container (selection)
</h2> </h2>
<p> <p>
The selection is what is shown to the user as a replacement of the The selection is what is shown to the user as a replacement of the
standard <code>&lt;select&gt;</code> box. It controls the display of the standard <code>&lt;select&gt;</code> box. It controls the display of the
selection option(s), as well anything else that needs to be embedded selection option(s), as well anything else that needs to be embedded
within the container, such as a search box. within the container, such as a search box.
</p> </p>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Key</dt> <dt>Key</dt>
<dd> <dd>
<code>selectionAdapter</code> <code>selectionAdapter</code>
</dd> </dd>
<dt>Default</dt> <dt>Default</dt>
<dd> <dd>
<code title="select2/selection/single">SingleSelection</code> or <code title="select2/selection/single">SingleSelection</code> or
<code title="select2/selection/multiple">MultipleSelection</code> <code title="select2/selection/multiple">MultipleSelection</code>
</dd> </dd>
<dt>Base</dt> <dt>Base</dt>
<dd> <dd>
<code title="select2/selection/base">BaseSelection</code> <code title="select2/selection/base">BaseSelection</code>
</dd> </dd>
</dl> </dl>
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
// Update the selected data. // Update the selected data.
@ -106,31 +106,31 @@ Adapter.destroy = function () { };
SelectionAdapter.update = function (data) { }; SelectionAdapter.update = function (data) { };
</pre> </pre>
<h2 id="dataAdapter"> <h2 id="dataAdapter">
Data set Data set
</h2> </h2>
<p> <p>
The data set is what Select2 uses to generate the possible results that The data set is what Select2 uses to generate the possible results that
can be selected, as well as the currently selected results. can be selected, as well as the currently selected results.
</p> </p>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Key</dt> <dt>Key</dt>
<dd> <dd>
<code>dataAdapter</code> <code>dataAdapter</code>
</dd> </dd>
<dt>Default</dt> <dt>Default</dt>
<dd> <dd>
<code title="select2/data/select">SelectAdapter</code> <code title="select2/data/select">SelectAdapter</code>
</dd> </dd>
<dt>Base</dt> <dt>Base</dt>
<dd> <dd>
<code title="select2/data/base">BaseAdapter</code> <code title="select2/data/base">BaseAdapter</code>
</dd> </dd>
</dl> </dl>
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
// Get the currently selected options. This is called when trying to get the // Get the currently selected options. This is called when trying to get the
@ -160,50 +160,50 @@ DataAdapter.query = function (params, callback) {
} }
</pre> </pre>
<h2 id="dropdownAdapter"> <h2 id="dropdownAdapter">
Dropdown Dropdown
</h2> </h2>
<p> <p>
The dropdown adapter defines the main container that the dropdown should The dropdown adapter defines the main container that the dropdown should
be held in. <strong>It does not define any extra methods that can be used be held in. <strong>It does not define any extra methods that can be used
for decorators</strong>, but it is common for decorators to attach to the for decorators</strong>, but it is common for decorators to attach to the
<code>render</code> and <code>position</code> methods to alter how the <code>render</code> and <code>position</code> methods to alter how the
dropdown is altered and positioned. dropdown is altered and positioned.
</p> </p>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Key</dt> <dt>Key</dt>
<dd> <dd>
<code>dropdownAdapter</code> <code>dropdownAdapter</code>
</dd> </dd>
<dt>Default</dt> <dt>Default</dt>
<dd> <dd>
<code title="select2/dropdown">DropdownAdapter</code> <code title="select2/dropdown">DropdownAdapter</code>
</dd> </dd>
</dl> </dl>
<h2 id="resultsAdapter"> <h2 id="resultsAdapter">
Results Results
</h2> </h2>
<p> <p>
The results adapter controls the list of results that the user can select The results adapter controls the list of results that the user can select
from. While the results adapter does not define any additional methods from. While the results adapter does not define any additional methods
that must be implemented, it makes extensive use of the Select2 event that must be implemented, it makes extensive use of the Select2 event
system for controlling the display of results and messages. system for controlling the display of results and messages.
</p> </p>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Key</dt> <dt>Key</dt>
<dd> <dd>
<code>resultsAdapter</code> <code>resultsAdapter</code>
</dd> </dd>
<dt>Default</dt> <dt>Default</dt>
<dd> <dd>
<code title="select2/results">ResultsAdapter</code> <code title="select2/results">ResultsAdapter</code>
</dd> </dd>
</dl> </dl>
</section> </section>

View File

@ -1,201 +1,200 @@
<section id="compatibility"> <section>
<div class="page-header"> <div class="page-header">
<h1>Backwards compatibility</h1> <h1 id="compatibility">Backwards compatibility</h1>
</div> </div>
<p> <p>
Select2 offers limited backwards compatibility with the previously 3.5.x Select2 offers limited backwards compatibility with the previously 3.5.x
release line, allowing people more efficiently transfer across releases release line, allowing people more efficiently transfer across releases
and get the latest features. For many of the larger changes, such as the and get the latest features. For many of the larger changes, such as the
change in how custom data adapters work, compatibility modules were change in how custom data adapters work, compatibility modules were
created that will be used to assist in the upgrade process. It is not created that will be used to assist in the upgrade process. It is not
recommended to rely on these compatibility modules, as they will not recommended to rely on these compatibility modules, as they will not
always exist, but they make upgrading easier for major changes. always exist, but they make upgrading easier for major changes.
</p> </p>
<p> <p>
<strong>The compatibility modules are only included in the <strong>The compatibility modules are only included in the
<a href="index.html#builds-full" class="alert-link">full builds</a> of <a href="index.html#builds-full" class="alert-link">full builds</a> of
Select2</strong>. These files end in <code>.full.js</code>, and the Select2</strong>. These files end in <code>.full.js</code>, and the
compatibility modules are prefixed with <code>select2/compat</code>. compatibility modules are prefixed with <code>select2/compat</code>.
</p> </p>
<h2 id="compat-matcher"> <h2 id="compat-matcher">
Simplified function for matching data objects Simplified function for matching data objects
</h2> </h2>
<p class="alert alert-info"> <p class="alert alert-info">
<a href="announcements-4.0.html#new-matcher" class="alert-link">Added in Select2 4.0.0.</a> <a href="announcements-4.0.html#new-matcher" class="alert-link">Added in Select2 4.0.0.</a>
This method was added to make upgrading easier from earlier versions of This method was added to make upgrading easier from earlier versions of
Select2. Select2.
</p> </p>
<p> <p>
During the <a href="announcements-4.0.html">Select2 4.0.0 release</a>, the During the <a href="announcements-4.0.html">Select2 4.0.0 release</a>, the
<code>matcher</code> function was changed to allow for more complex <code>matcher</code> function was changed to allow for more complex
matching of nested objects. matching of nested objects.
</p> </p>
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Key</dt> <dt>Key</dt>
<dd> <dd>
<code>matcher</code> <code>matcher</code>
</dd> </dd>
<dt>Value</dt> <dt>Value</dt>
<dd> <dd>
A function taking a search <code>term</code> and the data object A function taking a search <code>term</code> and the data object
<code>text</code>. <code>text</code>.
</dd> </dd>
</dl> </dl>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Adapter</dt> <dt>Adapter</dt>
<dd> <dd>
<code title="select2/compat/matcher">oldMatcher</code> <code title="select2/compat/matcher">oldMatcher</code>
</dd> </dd>
</dl> </dl>
</div> </div>
</div> </div>
<p> <p>
The <a href="examples.html#matcher">custom matcher example</a> provides a The <a href="examples.html#matcher">custom matcher example</a> provides a
guide for how to use this in your own application. For those upgrading guide for how to use this in your own application. For those upgrading
from older versions of Select2, you just need to wrap your old from older versions of Select2, you just need to wrap your old
<code>matcher</code> with this function to maintain compatibility. <code>matcher</code> with this function to maintain compatibility.
</p> </p>
<h2 id="initSelection"> <h2 id="initSelection">
Old initial selections with <code>initSelection</code> Old initial selections with <code>initSelection</code>
</h2> </h2>
<p class="alert alert-warning"> <p class="alert alert-warning">
<a href="announcements-4.0.html#removed-initselection" class="alert-link">Deprecated in Select2 4.0.</a> <a href="announcements-4.0.html#removed-initselection" class="alert-link">Deprecated in Select2 4.0.</a>
This has been replaced by another option and is only available in the This has been replaced by another option and is only available in the
<a href="index.html#builds-full" class="alert-link">full builds</a> of <a href="index.html#builds-full" class="alert-link">full builds</a> of
Select2. Select2.
</p> </p>
<p> <p>
In the past, Select2 required an option called <code>initSelection</code> In the past, Select2 required an option called <code>initSelection</code>
that was defined whenever a custom data source was being used, allowing that was defined whenever a custom data source was being used, allowing
for the initial selection for the component to be determined. This has for the initial selection for the component to be determined. This has
been replaced by the <code>current</code> method on the been replaced by the <code>current</code> method on the
<a href="#dataAdapter">data adapter</a>. <a href="#dataAdapter">data adapter</a>.
</p> </p>
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Key</dt> <dt>Key</dt>
<dd> <dd>
<code>initSelection</code> <code>initSelection</code>
</dd> </dd>
<dt>Value</dt> <dt>Value</dt>
<dd> <dd>
A function taking a <code>callback</code> A function taking a <code>callback</code>
</dd> </dd>
</dl> </dl>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Adapter</dt> <dt>Adapter</dt>
<dd> <dd>
<code title="select2/data/base">DataAdapter</code> <code title="select2/data/base">DataAdapter</code>
</dd> </dd>
<dt>Decorator</dt> <dt>Decorator</dt>
<dd> <dd>
<code title="select2/compat/initSelection">InitSelection</code> <code title="select2/compat/initSelection">InitSelection</code>
</dd> </dd>
</dl> </dl>
</div> </div>
</div> </div>
<h2 id="query"> <h2 id="query">
Querying old data with <code>query</code> Querying old data with <code>query</code>
</h2> </h2>
<p class="alert alert-warning"> <p class="alert alert-warning">
<a href="announcements-4.0.html#query-to-data-adapter" class="alert-link">Deprecated in Select2 4.0.</a> <a href="announcements-4.0.html#query-to-data-adapter" class="alert-link">Deprecated in Select2 4.0.</a>
This has been replaced by another option and is only available in the This has been replaced by another option and is only available in the
<a href="index.html#builds-full" class="alert-link">full builds</a> of <a href="index.html#builds-full" class="alert-link">full builds</a> of
Select2. Select2.
</p> </p>
<p> <p>
In the past, Select2 supported an option called <code>query</code> that In the past, Select2 supported an option called <code>query</code> that
allowed for a custom data source to be used. This option has been replaced allowed for a custom data source to be used. This option has been replaced
by the <code>query</code> method on the by the <code>query</code> method on the
<a href="#dataAdapter">data adapter</a> and takes a very similar set of <a href="#dataAdapter">data adapter</a> and takes a very similar set of
parameters. parameters.
</p> </p>
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Key</dt> <dt>Key</dt>
<dd> <dd>
<code>query</code> <code>query</code>
</dd> </dd>
<dt>Value</dt> <dt>Value</dt>
<dd> <dd>
A function taking <code>params</code> (including a <code>callback</code>) A function taking <code>params</code> (including a <code>callback</code>)
</dd> </dd>
</dl> </dl>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Adapter</dt> <dt>Adapter</dt>
<dd> <dd>
<code title="select2/data/base">DataAdapter</code> <code title="select2/data/base">DataAdapter</code>
</dd> </dd>
<dt>Decorator</dt> <dt>Decorator</dt>
<dd> <dd>
<code title="select2/compat/query">Query</code> <code title="select2/compat/query">Query</code>
</dd> </dd>
</dl> </dl>
</div> </div>
</div> </div>
</section>
<h2 id="input-fallback"> <h2 id="input-fallback">
Compatibility with <code>&lt;input type="text" /&gt;</code> Compatibility with <code>&lt;input type="text" /&gt;</code>
</h2> </h2>
<p class="alert alert-warning"> <p class="alert alert-warning">
<a href="announcements-4.0.html#hidden-input" class="alert-link">Deprecated in Select2 4.0.</a> <a href="announcements-4.0.html#hidden-input" class="alert-link">Deprecated in Select2 4.0.</a>
It is now encouraged to use the <code>&lt;select&gt;</code> tag instead. It is now encouraged to use the <code>&lt;select&gt;</code> tag instead.
</p> </p>
<p> <p>
In past versions of Select2, a <code>&lt;select&gt;</code> element could In past versions of Select2, a <code>&lt;select&gt;</code> element could
only be used with a limited subset of options. An only be used with a limited subset of options. An
<code>&lt;input type="hidden" /&gt;</code> was required instead, which did <code>&lt;input type="hidden" /&gt;</code> was required instead, which did
not allow for a graceful fallback for users who did not have JavaScript not allow for a graceful fallback for users who did not have JavaScript
enabled. Select2 now supports the <code>&lt;select&gt;</code> element for enabled. Select2 now supports the <code>&lt;select&gt;</code> element for
all options, so it is no longer required to use <code>&lt;input /&gt;</code> all options, so it is no longer required to use <code>&lt;input /&gt;</code>
elements with Select2. elements with Select2.
</p> </p>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Adapter</dt> <dt>Adapter</dt>
<dd> <dd>
<code title="select2/data/base">DataAdapter</code> <code title="select2/data/base">DataAdapter</code>
</dd> </dd>
<dt>Decorator</dt> <dt>Decorator</dt>
<dd> <dd>
<code title="select2/compat/inputData">InputData</code> <code title="select2/compat/inputData">InputData</code>
</dd> </dd>
</dl> </dl>
</section> </section>

File diff suppressed because it is too large Load Diff

View File

@ -1,116 +1,76 @@
<section id="dropdown"> <section>
<div class="page-header"> <div class="page-header">
<h1>Dropdown</h1> <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>
</div>
<p> <p>
Select2 allows you to change the way that the dropdown works, allowing you When the dropdown is attached to the body, you are not limited to just
to do anything from attach it to a different location in the document or displaying the dropdown below the container. Select2 will display above
add a search box. the container if there is not enough space below the container, but there
</p> 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="dropdownParent"> <h2 id="dropdown-attachContainer">
Attached to body Attached below the container
</h2> </h2>
<p> <p>
By default, Select2 will attach the dropdown to the end of the body and Select2 can place the dropdown directly after the selection container, so
will absolutely position it to appear below the selection container. it will appear in the same location within the DOM as the rest of Select2.
</p> </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>
<div class="row">
<div class="col-sm-6">
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Adapter</dt> <dt>Adapter</dt>
<dd> <dd>
@ -119,190 +79,230 @@
<dt>Decorator</dt> <dt>Decorator</dt>
<dd> <dd>
<code title="select2/dropdown/search">DropdownSearch</code> <code title="select2/dropdown/attachContainer">AttachContainer</code>
</dd> </dd>
</dl> </dl>
</div>
<p> <div class="col-sm-6">
A search box is added to the top of the dropdown automatically for select <div class="alert alert-warning">
boxes where only a single option can be selected. <strong>Check your build.</strong> This module is only included in the
</p> <a href="index.html#builds-full" class="alert-link">full builds</a> of
Select2.
<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> </div>
</div>
</div>
<h3 id="dropdown-maximumInputLength"> <div class="alert alert-info">
Maximum search term length to filter results <strong>
</h3> <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>
<p> <h2 id="dropdown-search">
In some cases, search terms need to be limited to a certain range. Select2 Search
allows you to limit the length of the search term such that it does not </h2>
exceed a certain length.
</p>
<div class="row"> <p>
<div class="col-sm-6"> Users can filter down the results by typing a search term into a box that
<dl class="dl-horizontal"> is displayed at the top of the dropdown.
<dt>Key</dt> </p>
<dd><code>maximumInputLength</code></dd>
<dt>Value</dt> <dl class="dl-horizontal">
<dd>integer</dd> <dt>Adapter</dt>
</dl> <dd>
</div> <code title="select2/dropdown">DropdownAdapter</code>
</dd>
<div class="col-sm-6"> <dt>Decorator</dt>
<dl class="dl-horizontal"> <dd>
<dt>Adapter</dt> <code title="select2/dropdown/search">DropdownSearch</code>
<dd> </dd>
<code title="select2/data/base">DataAdapter</code> </dl>
</dd>
<dt>Decorator</dt> <p>
<dd> A search box is added to the top of the dropdown automatically for select
<code title="select2/data/maximumInputLength">MaximumInputLength</code> boxes where only a single option can be selected.
</dd> </p>
</dl>
</div>
</div>
<h3 id="dropdown-maximumInputLength"> <h3 id="dropdown-minimumInputLength">
Minimum results to display the search box Minimum search term length to filter results
</h3> </h3>
<p> <p>
When working with smaller data sets, the search box can take up more space Sometimes when working with large data sets, it is more efficient to start
that is necessary, as there are not enough results for filtering to be filtering the results when the search term is a certain length. This is
effective. Select2 allows you to only display the search box when the very common when working with remote data sets, as allows for only
number of search results reaches a certain threshold. significant search terms to be used.
</p> </p>
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Key</dt> <dt>Key</dt>
<dd><code>minimumResultsForSearch</code></dd> <dd><code>minimumInputLength</code></dd>
<dt>Value</dt> <dt>Value</dt>
<dd>integer</dd> <dd>integer</dd>
</dl> </dl>
</div> </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>
<div class="col-sm-6">
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Adapter</dt> <dt>Adapter</dt>
<dd> <dd>
<code title="select2/results">ResultsAdapter</code> <code title="select2/data/base">DataAdapter</code>
</dd> </dd>
<dt>Decorator</dt> <dt>Decorator</dt>
<dd> <dd>
<code title="select2/dropdown/selectOnClose">SelectOnClose</code> <code title="select2/data/minimumInputLength">MinimumInputLength</code>
</dd> </dd>
</dl> </dl>
</div>
</div>
<h2 id="closeOnSelect"> <h3 id="dropdown-maximumInputLength">
Close the dropdown when a result is selected Maximum search term length to filter results
</h2> </h3>
<p> <p>
Select2 will automatically close the dropdown when an element is selected, In some cases, search terms need to be limited to a certain range. Select2
similar to what is done with a normal select box. This behavior can be allows you to limit the length of the search term such that it does not
changed though to keep the dropdown open when results are selected, exceed a certain length.
allowing for multiple options to be selected quickly. </p>
</p>
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Key</dt> <dt>Key</dt>
<dd><code>closeOnSelect</code></dd> <dd><code>maximumInputLength</code></dd>
<dt>Default</dt> <dt>Value</dt>
<dd><code>true</code></dd> <dd>integer</dd>
</dl> </dl>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Adapter</dt> <dt>Adapter</dt>
<dd> <dd>
<code title="select2/dropdown">DropdownAdapter</code> <code title="select2/data/base">DataAdapter</code>
</dd> </dd>
<dt>Decorator</dt> <dt>Decorator</dt>
<dd> <dd>
<code title="select2/dropdown/closeOnSelect">CloseOnSelect</code> <code title="select2/data/maximumInputLength">MaximumInputLength</code>
</dd> </dd>
</dl> </dl>
</div> </div>
</div> </div>
<p> <h3 id="dropdown-maximumInputLength">
If this decorator is not used (or <code>closeOnSelect</code> is set to Minimum results to display the search box
<code>false</code>), the dropdown will not automatically close when a </h3>
result is selected. The dropdown will also never close if the
<kbd>ctrl</kbd> key is held down when the result is selected. <p>
</p> When working with smaller data sets, the search box can take up more space
</section> 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>

View File

@ -1,50 +1,50 @@
<section id="events"> <section>
<div class="page-header"> <div id="events" class="page-header">
<h1>Events</h1> <h1>Events</h1>
</div> </div>
<p> <p>
Select2 has an internal event system that is used to notify parts of the Select2 has an internal event system that is used to notify parts of the
component that state has changed, as well as an adapter that allows some component that state has changed, as well as an adapter that allows some
of these events to be relayed to the outside word. of these events to be relayed to the outside word.
</p> </p>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Adapter</dt> <dt>Adapter</dt>
<dd> <dd>
<code title="select2/selection">SelectionAdapter</code> <code title="select2/selection">SelectionAdapter</code>
</dd> </dd>
<dt>Decorator</dt> <dt>Decorator</dt>
<dd> <dd>
<code title="select2/selection/eventRelay">EventRelay</code> <code title="select2/selection/eventRelay">EventRelay</code>
</dd> </dd>
</dl> </dl>
<h2 id="events-public"> <h2 id="events-public">
Public events Public events
</h2> </h2>
<p> <p>
All public events are relayed using the jQuery event system, and they are All public events are relayed using the jQuery event system, and they are
triggered on the <code>&lt;select&gt;</code> element that Select2 is triggered on the <code>&lt;select&gt;</code> element that Select2 is
attached to. You can attach to them using the attached to. You can attach to them using the
<a href="https://api.jquery.com/on/"><code>.on</code> method</a> provided <a href="https://api.jquery.com/on/"><code>.on</code> method</a> provided
by jQuery. by jQuery.
</p> </p>
<h2 id="events-internal"> <h2 id="events-internal">
Internal events Internal events
</h2> </h2>
<p> <p>
Select2 triggers internal events using its own internal event system, Select2 triggers internal events using its own internal event system,
which allows adapters to communicate with each other. These events are not which allows adapters to communicate with each other. These events are not
accessible through the jQuery event system. accessible through the jQuery event system.
</p> </p>
<p> <p>
You can find more information on the public events triggered by individual You can find more information on the public events triggered by individual
adapters in <a href="#adapters">the individual adapter documentation</a>. adapters in <a href="#adapters">the individual adapter documentation</a>.
</p> </p>
</section> </section>