Commit 1d6dc331 authored by David Stutz's avatar David Stutz

Added example for #129, documentation for #281, #356 in FAQ.

parent 3cfdfaab
...@@ -222,6 +222,8 @@ $(document).ready(function() { ...@@ -222,6 +222,8 @@ $(document).ready(function() {
$('#example46').multiselect({ $('#example46').multiselect({
checkboxName: 'multiselect-checkbox' checkboxName: 'multiselect-checkbox'
}); });
$('#example48').multiselect();
}); });
</script> </script>
...@@ -244,6 +246,21 @@ $(document).ready(function() { ...@@ -244,6 +246,21 @@ $(document).ready(function() {
Normal select. The plugin will do single selection using radio buttons rather than multiple selection using checkboxes. Normal select. The plugin will do single selection using radio buttons rather than multiple selection using checkboxes.
</td> </td>
</tr> </tr>
<tr>
<td>
<select id="example48" size="2">
<option value="cheese">Cheese</option>
<option value="tomatoes">Tomatoes</option>
<option value="mozarella">Mozzarella</option>
<option value="mushrooms">Mushrooms</option>
<option value="pepperoni">Pepperoni</option>
<option value="onions">Onions</option>
</select>
</td>
<td>
Single selection without having the browser select the first option.
</td>
</tr>
<tr> <tr>
<td> <td>
<select id="example2" multiple="multiple"> <select id="example2" multiple="multiple">
...@@ -1213,6 +1230,20 @@ $(document).ready(function() { ...@@ -1213,6 +1230,20 @@ $(document).ready(function() {
$('#example36-enable').on('click', function() { $('#example36-enable').on('click', function() {
$('#example36').multiselect('enable'); $('#example36').multiselect('enable');
}); });
var data = [
{label: 'Cheese', value: 'cheese'},
{label: 'Tomatoes', value: 'tomatoes'}
];
$('#example49').multiselect();
$('#example49').multiselect('dataprovider', data);
var data = [
{title: 'First group', children: [{label: 'Cheese', value: 'cheese'}, {label: 'Tomatoes', value: 'tomatoes'}]},
{title: 'Second group', children: [{label: 'Mozzarella', value: 'mozzarella'}, {label: 'Mushrooms', value: 'mushrooms'}]},
];
$('#example50').multiselect();
$('#example50').multiselect('dataprovider', data);
}); });
</script> </script>
<table class="table table-striped"> <table class="table table-striped">
...@@ -1224,7 +1255,7 @@ $(document).ready(function() { ...@@ -1224,7 +1255,7 @@ $(document).ready(function() {
This method is used to destroy the plugin on the given element - meaning unbinding the plugin. This method is used to destroy the plugin on the given element - meaning unbinding the plugin.
</p> </p>
</td> </td>
<td> <td width="50%">
<div class="btn-group"> <div class="btn-group">
<select id="example8" multiple="multiple"> <select id="example8" multiple="multiple">
<option value="cheese">Cheese</option> <option value="cheese">Cheese</option>
...@@ -1330,18 +1361,33 @@ $(document).ready(function() { ...@@ -1330,18 +1361,33 @@ $(document).ready(function() {
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td>
<p><code>.multiselect('dataprovider', data)</code></p> <p><code>.multiselect('dataprovider', data)</code></p>
<p> <p>
Provides data for building the select's options the following way: Provides data for building the select's options the following way:
</p> </p>
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
var data = [ var data = [
{label: &quot;ACNP&quot;, value: &quot;ACNP&quot;}, {label: 'Cheese', value: 'cheese'},
{label: &quot;test&quot;, value: &quot;test&quot;} {label: 'Tomatoes', value: 'tomatoes'}
]; ];
$(&quot;#multiselect&quot;).multiselect('dataprovider', data); $(&quot;#multiselect&quot;).multiselect('dataprovider', data);
</pre> </pre>
<p>
Alternatively, this method can also be used to build option groups (<a target="_blank" href="https://github.com/davidstutz/bootstrap-multiselect/pull/281">#281</a>):
</p>
<pre class="prettyprint linenums">
var data = [
{title: 'First group', children: [{label: 'Cheese', value: 'cheese'}, {label: 'Tomatoes', value: 'tomatoes'}]},
{title: 'Second group', children: [{label: 'Mozzarella', value: 'mozzarella'}, {label: 'Mushrooms', value: 'mushrooms'}]},
];
$('.multiselect').multiselect('dataprovider', data);
</pre>
</td>
<td>
<select id="example49" multiple="multiple"></select>
<select id="example50" multiple="multiple"></select>
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -2421,6 +2467,13 @@ validator.settings.ignore = ':hidden:not(".multiselect")'; ...@@ -2421,6 +2467,13 @@ validator.settings.ignore = ':hidden:not(".multiselect")';
<p> <p>
The plugin needs at least the styles for forms and dropdowns. In addition the JavaScript dropdown plugin from Twitter Bootstrap is required. Details can be found here: <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/344">#344</a>. The plugin needs at least the styles for forms and dropdowns. In addition the JavaScript dropdown plugin from Twitter Bootstrap is required. Details can be found here: <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/344">#344</a>.
</p> </p>
<p>
<b>How to use the <code>.multiselect('dataprovider', data)</code> method?</b>
</p>
<p>
Have a look at the <a href="#methods">Methods</a> section. In the past, there has been some confusion about how the method handles option groups. If the documentation does not help you, have a look at the issue tracker, as for example issue <a target="_blank" href="https://github.com/davidstutz/bootstrap-multiselect/issues/356">356</a>.
</p>
</div> </div>
<div class="container"> <div class="container">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment