Commit 6eb86d07 authored by David Stutz's avatar David Stutz

Example for #163.

parent 13219440
......@@ -802,14 +802,14 @@ $("#multiselect").multiselect('dataprovider', data);
case 2:
rebuildMultiselect(firstConfigurationSet);
$(this).text('Configuration Set 1');
$(this).text('Configuration Set 2');
set = 1;
break;
case 1:
default:
rebuildMultiselect(secondConfigurationSet);
$(this).text('Configuration Set 2');
$(this).text('Configuration Set 1');
set = 2;
break;
......@@ -820,7 +820,7 @@ $("#multiselect").multiselect('dataprovider', data);
<table class="table table-striped">
<tbody>
<tr>
<td style="width:300px">
<td style="width:350px">
<div class="btn-group">
<select id="example21" multiple="multiple">
<option value="cheese">Cheese</option>
......@@ -922,9 +922,11 @@ $(&quot;#multiselect&quot;).multiselect('dataprovider', data);
buttonText: function(options) {
if (options.length == 0) {
return 'None selected &lt;b class=&quot;caret&quot;&gt;&lt;/b&gt;';
} else if (options.length &gt; 6) {
}
else if (options.length &gt; 6) {
return options.length + ' selected &lt;b class=&quot;caret&quot;&gt;&lt;/b&gt;';
} else {
}
else {
var selected = '';
options.each(function() {
selected += $(this).text() + ', ';
......@@ -935,10 +937,12 @@ $(&quot;#multiselect&quot;).multiselect('dataprovider', data);
onChange: function(element, checked) {
if(checked == true) {
// action taken here if true
} else if (checked == false) {
}
else if (checked == false) {
if (confirm('Do you wish to deselect the element?')) {
// action taken here
} else {
}
else {
$(&quot;#example22&quot;).multiselect('select', element.val());
return false;
}
......@@ -964,6 +968,39 @@ $(&quot;#multiselect&quot;).multiselect('dataprovider', data);
<button id="example33-configuration-set" class="btn btn-primary">Configuration Set 2</button>
</div>
</td>
<td>
<pre class="linenums prettyprint">
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function() {
var set = 1;
$('#example33').multiselect(firstConfigurationSet);
function rebuildMultiselect(options) {
$('#example33').multiselect('setOptions', options);
$('#example33').multiselect('rebuild');
}
$('#example33-configuration-set').on('click', function(event) {
switch (set) {
case 2:
rebuildMultiselect(firstConfigurationSet);
$(this).text('Configuration Set 2');
set = 1;
break;
case 1:
default:
rebuildMultiselect(secondConfigurationSet);
$(this).text('Configuration Set 1');
set = 2;
break;
}
});
});
&lt;/script&gt;
</pre>
</td>
</tr>
</tbody>
</table>
......
......@@ -367,7 +367,7 @@
// Add the select all option to the select.
buildSelectAll: function() {
var alreadyHasSelectAll = this.$select[0][0] ? this.$select[0][0].value == this.options.selectAllValue : false;
console.log(this.options);
// If options.includeSelectAllOption === true, add the include all checkbox.
if (this.options.includeSelectAllOption && this.options.multiple && !alreadyHasSelectAll) {
this.$select.prepend('<option value="' + this.options.selectAllValue + '">' + this.options.selectAllText + '</option>');
......@@ -532,6 +532,9 @@
rebuild: function() {
this.$ul.html('');
// Remove select all option in select.
$('option[value="' + this.options.selectAllValue + '"]', this.$select).remove();
// Important to distinguish between radios and checkboxes.
this.options.multiple = this.$select.attr('multiple') == "multiple";
......
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