Commit 7f80e5aa authored by David HAN SZE CHUEN's avatar David HAN SZE CHUEN

Show that the dataprovider method supports `selected` and `caption` properties

parent 9571dd5b
...@@ -1309,20 +1309,29 @@ $(document).ready(function() { ...@@ -1309,20 +1309,29 @@ $(document).ready(function() {
$('#example36-enable').on('click', function() { $('#example36-enable').on('click', function() {
$('#example36').multiselect('enable'); $('#example36').multiselect('enable');
}); });
var data = [ var data = [
{label: 'Cheese', value: 'cheese'}, { label: 'Cheese', value: 'cheese', caption: 'Swiss cheese' },
{label: 'Tomatoes', value: 'tomatoes'} { label: 'Tomatoes', value: 'tomatoes', caption: 'Red tomato', selected: true }
]; ];
$('#example49').multiselect(); $('#example49').multiselect().multiselect('dataprovider', data);
$('#example49').multiselect('dataprovider', data);
var 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'}]}, title: 'First group',
children: [
{ label: 'Cheese', value: 'cheese', caption: 'Swiss cheese', selected: true },
{ label: 'Tomatoes', value: 'tomatoes', caption: 'Red tomato' }
]
}, {
title: 'Second group',
children: [
{ label: 'Mozzarella', value: 'mozzarella', caption: 'Italian cheese' },
{ label: 'Mushrooms', value: 'mushrooms', caption: 'French mushroom' }
]
}
]; ];
$('#example50').multiselect(); $('#example50').multiselect().multiselect('dataprovider', data);
$('#example50').multiselect('dataprovider', data);
}); });
</script> </script>
<table class="table table-striped"> <table class="table table-striped">
...@@ -1445,21 +1454,32 @@ $(document).ready(function() { ...@@ -1445,21 +1454,32 @@ $(document).ready(function() {
<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" style="max-width: none">
var data = [ var data = [
{label: 'Cheese', value: 'cheese'}, { label: 'Cheese', value: 'cheese', caption: 'Swiss cheese', selected: true },
{label: 'Tomatoes', value: 'tomatoes'} { label: 'Tomatoes', value: 'tomatoes', caption: 'Red tomato' }
]; ];
$(&quot;#multiselect&quot;).multiselect('dataprovider', data); $('multiselect').multiselect('dataprovider', data);
</pre> </pre>
<p> <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>): 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> </p>
<pre class="prettyprint linenums"> <pre class="prettyprint linenums" style="max-width: none">
var 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'}]}, title: 'First group',
children: [
{ label: 'Cheese', value: 'cheese', caption: 'Swiss cheese' },
{ label: 'Tomatoes', value: 'tomatoes', caption: 'Red tomato', selected: true }
]
}, {
title: 'Second group',
children: [
{ label: 'Mozzarella', value: 'mozzarella', caption: 'Italian cheese' },
{ label: 'Mushrooms', value: 'mushrooms', caption: 'French mushroom' }
]
}
]; ];
$('.multiselect').multiselect('dataprovider', data); $('.multiselect').multiselect('dataprovider', data);
</pre> </pre>
......
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