1
0
mirror of synced 2024-11-25 06:16:08 +03:00

Revert "Add documentation for hideSelectionFromResult"

This reverts commit 916bb14414.

New problems found in:
https://github.com/ivaynberg/select2/issues/2196

Original issue:
https://github.com/ivaynberg/select2/issues/1538

Pull request:
https://github.com/ivaynberg/select2/pull/2032
This commit is contained in:
Kevin Brown 2014-04-05 10:35:33 -04:00
parent 729df0cf16
commit df454ef6b2
2 changed files with 16 additions and 140 deletions

View File

@ -223,7 +223,6 @@ $("#e10_4").select2({
<li><a href="#sort_results">Sorting Displayed Results</a></li> <li><a href="#sort_results">Sorting Displayed Results</a></li>
<li><a href="#responsive">Responsive Design</a></li> <li><a href="#responsive">Responsive Design</a></li>
<li><a href="#diacritics">Diacritics Support</a></li> <li><a href="#diacritics">Diacritics Support</a></li>
<li><a href="#allow_duplicated_tags">Allow duplicated tags</a></li>
</ul> </ul>
</li> </li>
<li><a href="#documentation">Documentation</a></li> <li><a href="#documentation">Documentation</a></li>
@ -1077,36 +1076,6 @@ $(document).ready(function () {
</div> </div>
</article> </article>
<article class="row" id="allow_duplicated_tags">
<div class="span12">
<h3>Allow duplicated tags</h3>
<p>In multiple mode, select2 doesn't allow the same tag to be selected more than once. This default behavior can be overridden by implementing the <code>hideSelectionFromResult</code> function:</p>
<p>
<select id="e31" multiple="multiple" style="width:300px;">
<option>Red</option>
<option>Green</option>
<option>Blue</option>
</select>
</p>
<script id="script_e25">
function hideSelection(selectedObject) {
return false;
};
$('#e31').select2({
hideSelectionFromResult: hideSelection
});
</script>
<div class="span12">
<h3>Example Code</h3>
<pre class="prettyprint linenums" id="code_e25"></pre>
</div>
</div>
</article>
</section>
<!-- --> <!-- -->
<!-- DOCUMENTATION --> <!-- DOCUMENTATION -->
<!-- --> <!-- -->
@ -1667,38 +1636,6 @@ $("#select").select2({
</pre> </pre>
<p class="alert alert-info">Function can be used when the dropdown is configured in single and multi-select mode. It is triggered after selecting an item. In single mode it is also triggered after initSelection (when provided).</p> <p class="alert alert-info">Function can be used when the dropdown is configured in single and multi-select mode. It is triggered after selecting an item. In single mode it is also triggered after initSelection (when provided).</p>
</td></tr> </td></tr>
<tr><td>hideSelectionFromResult</td><td>function</td><td>
<p>Function that determines if the selected item should be displayed or hidden from the result list.</p>
<table class="table table-bordered table-striped">
<tbody>
<tr><th>Parameter</th><th>Type</th><th>Description</th></tr>
<tr><td>data</td><td>object</td><td>Selected data.</td></tr>
</tbody>
</table>
<p>By default, the selected item is visible in the result list in single mode and hidden in multi-select mode.
This behavior can be overridden by implementing the <code>hideSelectionFromResult</code> function.</p>
<p>For instance, in the case of a single select box it can be used to hide the selected item from the result list:</p>
<pre class="prettyprint">
function hideSelectedItem(selectedObject){
return true;
}
$("#e1").select2({
hideSelectionFromResult: hideSelectedItem
})
</pre>
<p>More complex behavior can be achieved by reading the text of the selected item:</p>
<pre class="prettyprint">
function hideAlaskaFromResult(selectedObject){
return selectedObject.data("select2-data").text == "Alaska" ? true : false;
}
$("#e1").select2({
hideSelectionFromResult: hideAlaskaFromResult
})
</pre>
<p class="alert alert-info">The return value of <code>hideSelectionFromResult</code> is a boolean. It returns undefined if it is not implemented.</p>
</td></tr>
</table> </table>
<div class="row"> <div class="row">

View File

@ -233,7 +233,6 @@ $("#e10_4").select2({
<li><a href="#sort_results">Sorting Displayed Results</a></li> <li><a href="#sort_results">Sorting Displayed Results</a></li>
<li><a href="#responsive">Responsive Design</a></li> <li><a href="#responsive">Responsive Design</a></li>
<li><a href="#diacritics">Diacritics Support</a></li> <li><a href="#diacritics">Diacritics Support</a></li>
<li><a href="#allow_duplicated_tags">Allow duplicated tags</a></li>
</ul> </ul>
</li> </li>
<li><a href="#documentation">Documentation</a></li> <li><a href="#documentation">Documentation</a></li>
@ -980,7 +979,7 @@ $("#e18,#e18_2").select2();
<article class="row" id="disabled-options"> <article class="row" id="disabled-options">
<script id="script_e24"> <script id="script_e24">
$(document).ready(function () { $(document).ready(function () {
$('#e24').select2({ $('#e24').select2({
query: function (query){ query: function (query){
var data = { var data = {
@ -994,8 +993,7 @@ $(document).ready(function () {
query.callback(data); query.callback(data);
} }
}); });
}); });
</script> </script>
<div class="span12"> <div class="span12">
<h3>Disabled options</h3> <h3>Disabled options</h3>
@ -1043,7 +1041,6 @@ $(document).ready(function () {
}); });
$('#e21').select2('data', preload_data ) $('#e21').select2('data', preload_data )
}); });
</script> </script>
<div class="span12"> <div class="span12">
<h3>Lock selections</h3> <h3>Lock selections</h3>
@ -1087,33 +1084,7 @@ $(document).ready(function () {
</div> </div>
</article> </article>
<article class="row" id="allow_duplicated_tags">
<div class="span12">
<h3>Allow duplicated tags</h3>
<p>In multiple mode, select2 doesn't allow the same tag to be selected more than once. This default behavior can be overridden by implementing the <code>hideSelectionFromResult</code> function:</p>
<p>
<select id="e31" multiple="multiple" style="width:300px;">
<option>Red</option>
<option>Green</option>
<option>Blue</option>
</select>
</p>
<script id="script_e25">
function hideSelection(selectedObject) {
return false;
};
$('#e31').select2({
hideSelectionFromResult: hideSelection
});
</script>
<div class="span12">
<h3>Example Code</h3>
<pre class="prettyprint linenums" id="code_e25"></pre>
</div>
</div>
</article>
</section> </section>
@ -1677,38 +1648,6 @@ $("#select").select2({
</pre> </pre>
<p class="alert alert-info">Function can be used when the dropdown is configured in single and multi-select mode. It is triggered after selecting an item. In single mode it is also triggered after initSelection (when provided).</p> <p class="alert alert-info">Function can be used when the dropdown is configured in single and multi-select mode. It is triggered after selecting an item. In single mode it is also triggered after initSelection (when provided).</p>
</td></tr> </td></tr>
<tr><td>hideSelectionFromResult</td><td>function</td><td>
<p>Function that determines if the selected item should be displayed or hidden from the result list.</p>
<table class="table table-bordered table-striped">
<tbody>
<tr><th>Parameter</th><th>Type</th><th>Description</th></tr>
<tr><td>data</td><td>object</td><td>Selected data.</td></tr>
</tbody>
</table>
<p>By default, the selected item is visible in the result list in single mode and hidden in multi-select mode.
This behavior can be overridden by implementing the <code>hideSelectionFromResult</code> function.</p>
<p>For instance, in the case of a single select box it can be used to hide the selected item from the result list:</p>
<pre class="prettyprint">
function hideSelectedItem(selectedObject){
return true;
}
$("#e1").select2({
hideSelectionFromResult: hideSelectedItem
})
</pre>
<p>More complex behavior can be achieved by reading the text of the selected item:</p>
<pre class="prettyprint">
function hideAlaskaFromResult(selectedObject){
return selectedObject.data("select2-data").text == "Alaska" ? true : false;
}
$("#e1").select2({
hideSelectionFromResult: hideAlaskaFromResult
})
</pre>
<p class="alert alert-info">The return value of <code>hideSelectionFromResult</code> is a boolean. It returns undefined if it is not implemented.</p>
</td></tr>
</table> </table>
<div class="row"> <div class="row">