Commit ebd00ed5 authored by David Stutz's avatar David Stutz

Fixed #253 with extended example.

parent 7147dbda
...@@ -553,7 +553,7 @@ ...@@ -553,7 +553,7 @@
<tr> <tr>
<th>Option</th> <th>Option</th>
<th>Explanation</th> <th>Explanation</th>
<th>Usage</th> <th width="50%">Usage</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -920,7 +920,10 @@ ...@@ -920,7 +920,10 @@
$('#example8-destroy').on('click', function() { $('#example8-destroy').on('click', function() {
$('#example8').multiselect('destroy'); $('#example8').multiselect('destroy');
}); });
$('#example8-create').on('click', function() {
$('#example8').multiselect();
});
$('#example10').multiselect(); $('#example10').multiselect();
$('#example10-select').on('click', function() { $('#example10-select').on('click', function() {
$('option[value="tomatoes"]', $('#example10')).prop('selected', true); $('option[value="tomatoes"]', $('#example10')).prop('selected', true);
...@@ -1005,6 +1008,7 @@ ...@@ -1005,6 +1008,7 @@
<option value="onions">Onions</option> <option value="onions">Onions</option>
</select> </select>
<button id="example8-destroy" class="btn btn-danger">Destroy/Unbind</button> <button id="example8-destroy" class="btn btn-danger">Destroy/Unbind</button>
<button id="example8-create" class="btn btn-success">Create/Bind</button>
</div> </div>
</td> </td>
</tr> </tr>
...@@ -1455,7 +1459,7 @@ $(&quot;#multiselect&quot;).multiselect('dataprovider', data); ...@@ -1455,7 +1459,7 @@ $(&quot;#multiselect&quot;).multiselect('dataprovider', data);
<table class="table table-striped"> <table class="table table-striped">
<tbody> <tbody>
<tr> <tr>
<td style="width:400px"> <td>
<p> <p>
Use "Select" and "Deselect" to select or deselect cheese and tomatoes. Use "Values" to display the currently selected elements by using <code>$('.multiselect').val()</code>. Use "Select" and "Deselect" to select or deselect cheese and tomatoes. Use "Values" to display the currently selected elements by using <code>$('.multiselect').val()</code>.
</p> </p>
...@@ -1474,7 +1478,7 @@ $(&quot;#multiselect&quot;).multiselect('dataprovider', data); ...@@ -1474,7 +1478,7 @@ $(&quot;#multiselect&quot;).multiselect('dataprovider', data);
</div> </div>
<div id="example34-text" style="margin-top:6px;"></div> <div id="example34-text" style="margin-top:6px;"></div>
</td> </td>
<td> <td width="60%">
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
&lt;script type=&quot;text/javascript&quot;&gt; &lt;script type=&quot;text/javascript&quot;&gt;
$('#example34').multiselect(); $('#example34').multiselect();
......
...@@ -702,7 +702,7 @@ ...@@ -702,7 +702,7 @@
</tr> </tr>
<tr> <tr>
<td><code>selectedClass</code></td> <td><code>selectedClass</code></td>
<td>The class applied to the parent &lt;li&gt; of selected items. Default: <code>active</code>.</td> <td>The class applied to the parent <code>&lt;li&gt;</code> of selected items. Default: <code>active</code>.</td>
<td> <td>
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
&lt;script type=&quot;text/javascript&quot;&gt; &lt;script type=&quot;text/javascript&quot;&gt;
...@@ -921,7 +921,10 @@ ...@@ -921,7 +921,10 @@
$('#example8-destroy').on('click', function() { $('#example8-destroy').on('click', function() {
$('#example8').multiselect('destroy'); $('#example8').multiselect('destroy');
}); });
$('#example8-create').on('click', function() {
$('#example8').multiselect();
});
$('#example10').multiselect(); $('#example10').multiselect();
$('#example10-select').on('click', function() { $('#example10-select').on('click', function() {
$('option[value="tomatoes"]', $('#example10')).prop('selected', true); $('option[value="tomatoes"]', $('#example10')).prop('selected', true);
...@@ -1006,6 +1009,7 @@ ...@@ -1006,6 +1009,7 @@
<option value="onions">Onions</option> <option value="onions">Onions</option>
</select> </select>
<button id="example8-destroy" class="btn btn-danger">Destroy/Unbind</button> <button id="example8-destroy" class="btn btn-danger">Destroy/Unbind</button>
<button id="example8-create" class="btn btn-success">Create/Bind</button>
</div> </div>
</td> </td>
</tr> </tr>
...@@ -1456,7 +1460,7 @@ $(&quot;#multiselect&quot;).multiselect('dataprovider', data); ...@@ -1456,7 +1460,7 @@ $(&quot;#multiselect&quot;).multiselect('dataprovider', data);
<table class="table table-striped"> <table class="table table-striped">
<tbody> <tbody>
<tr> <tr>
<td style="width:400px"> <td>
<p> <p>
Use "Select" and "Deselect" to select or deselect cheese and tomatoes. Use "Values" to display the currently selected elements by using <code>$('.multiselect').val()</code>. Use "Select" and "Deselect" to select or deselect cheese and tomatoes. Use "Values" to display the currently selected elements by using <code>$('.multiselect').val()</code>.
</p> </p>
......
...@@ -881,15 +881,20 @@ ...@@ -881,15 +881,20 @@
return this.each(function() { return this.each(function() {
var data = $(this).data('multiselect'); var data = $(this).data('multiselect');
var options = typeof option === 'object' && option; var options = typeof option === 'object' && option;
// Initialize the multiselect. // Initialize the multiselect.
if (!data) { if (!data) {
$(this).data('multiselect', ( data = new Multiselect(this, options))); data = new Multiselect(this, options);
$(this).data('multiselect', data);
} }
// Call multiselect method. // Call multiselect method.
if (typeof option === 'string') { if (typeof option === 'string') {
data[option](parameter); data[option](parameter);
if (option === 'destroy') {
$(this).data('multiselect', false);
}
} }
}); });
}; };
......
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