Commit e7c8abfe authored by David Stutz's avatar David Stutz

Test for #709.

parent 9ec68114
...@@ -2990,7 +2990,7 @@ ...@@ -2990,7 +2990,7 @@
<table class="table layout-fixed"> <table class="table layout-fixed">
<tbody> <tbody>
<tr> <tr>
<td> <td width="30%">
<code>.multiselect('destroy')</code> <code>.multiselect('destroy')</code>
</td> </td>
<td> <td>
...@@ -3998,20 +3998,12 @@ ...@@ -3998,20 +3998,12 @@
&lt;select id=&quot;example-dataprovider-optgroups&quot; multiple=&quot;multiple&quot;&gt;&lt;/select&gt; &lt;select id=&quot;example-dataprovider-optgroups&quot; multiple=&quot;multiple&quot;&gt;&lt;/select&gt;
</pre> </pre>
</div> </div>
</td>
</tr> <p>
<tr>
<td>
</td>
<td>
<p>
You can add custom data attributes on option group children and non-grouped options: You can add custom data attributes on option group children and non-grouped options:
</p> </p>
<p>
Renders as: <pre class="prettyprint">&lt;option value=&quot;1&quot; label=&quot;Option 1&quot; selected=&quot;selected&quot; data-some-attribute=&quot;1&quot; data-another-attribute=&quot;false&quot;&gt;&lt;/option&gt; <div class="example">
&lt;option value=&quot;2&quot; label=&quot;Option 2&quot; data-some-attribute=&quot;2&quot;&gt;&lt;/option&gt;</pre>
</p>
<div class="example">
<div class="btn-group"> <div class="btn-group">
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
...@@ -4042,7 +4034,7 @@ ...@@ -4042,7 +4034,7 @@
</div> </div>
<div class="highlight"> <div class="highlight">
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
$(&#39;#example-dataprovider-data-attributes&#39;).multiselect(); $(&#39;#example-dataprovider-data-attributes&#39;).multiselect();
...@@ -4070,8 +4062,15 @@ ...@@ -4070,8 +4062,15 @@
&lt;/script&gt; &lt;/script&gt;
&lt;select id=&quot;example-dataprovider-data-attributes&quot; multiple=&quot;multiple&quot;&gt;&lt;/select&gt; &lt;select id=&quot;example-dataprovider-data-attributes&quot; multiple=&quot;multiple&quot;&gt;&lt;/select&gt;
</pre> </pre>
</div>
</div> </div>
</div> <p>
Renders as:
</p>
<pre class="prettyprint">
&lt;option value=&quot;1&quot; label=&quot;Option 1&quot; selected=&quot;selected&quot; data-some-attribute=&quot;1&quot; data-another-attribute=&quot;false&quot;&gt;&lt;/option&gt;
&lt;option value=&quot;2&quot; label=&quot;Option 2&quot; data-some-attribute=&quot;2&quot;&gt;&lt;/option&gt;
</pre>
</td> </td>
</tr> </tr>
<tr> <tr>
......
...@@ -360,13 +360,17 @@ describe('Bootstrap Multiselect "Dataprovider"', function() { ...@@ -360,13 +360,17 @@ describe('Bootstrap Multiselect "Dataprovider"', function() {
}); });
var options = [ var options = [
{label: 'Option 1', value: '1', selected: true, title: 'Option 1 Title'}, {label: 'Option 1', value: '1', selected: true, title: 'Option 1 Title'},
{label: 'Option 2', value: '2', title: 'Option 2 Title'}, {label: 'Option 2', value: '2', title: 'Option 2 Title'},
{label: 'Option 3', value: '3', selected: true, title: 'Option 3 Title'}, {label: 'Option 3', value: '3', selected: true, title: 'Option 3 Title'},
{label: 'Option 4', value: '4', title: 'Option 4 Title'}, {label: 'Option 4', value: '4', title: 'Option 4 Title'},
{label: 'Option 5', value: '5', title: 'Option 5 Title'}, {label: 'Option 5', value: '5', title: 'Option 5 Title'},
{label: 'Option 6', value: '6', title: 'Option 6 Title'} {label: 'Option 6', value: '6', title: 'Option 6 Title'}
]; ];
var options_attributes = [
{label: 'Option 1', value: '1', attributes: {'some-attribute': 'test'}}
];
it("Should be able to add options.", function() { it("Should be able to add options.", function() {
$('#multiselect').multiselect('dataprovider', options); $('#multiselect').multiselect('dataprovider', options);
...@@ -416,6 +420,12 @@ describe('Bootstrap Multiselect "Dataprovider"', function() { ...@@ -416,6 +420,12 @@ describe('Bootstrap Multiselect "Dataprovider"', function() {
expect($('#multiselect-container input[value="6"]').closest('label').attr('title')).toBe('Option 6 Title'); expect($('#multiselect-container input[value="6"]').closest('label').attr('title')).toBe('Option 6 Title');
}); });
it("Should be able to define data attributes.", function() {
$('#multiselect').multiselect('dataprovider', options_attributes)
expect($('#multiselect option[value="1"]').attr('value')).toBe('1');
expect($('#multiselect option[value="1"]').attr('data-some-attribute')).toBe('test');
});
var optgroups = [ var optgroups = [
{ {
label: 'Group 1', children: [ label: 'Group 1', children: [
...@@ -630,7 +640,7 @@ describe('Bootstrap Multiselect "Select All".', function() { ...@@ -630,7 +640,7 @@ describe('Bootstrap Multiselect "Select All".', function() {
}); });
}); });
describe('Bootstrap Multiselect Specific Issues', function() { describe('Bootstrap Multiselect Specific Issues.', function() {
it('#393', function() { it('#393', function() {
var $select = $('<select id="multiselect" multiple="multiple"></select>'); var $select = $('<select id="multiselect" multiple="multiple"></select>');
...@@ -706,7 +716,7 @@ describe('Bootstrap Multiselect Specific Issues', function() { ...@@ -706,7 +716,7 @@ describe('Bootstrap Multiselect Specific Issues', function() {
}); });
}); });
describe('Knockout Binding', function() { describe('Knockout Binding.', function() {
var $testArea; var $testArea;
afterEach(function() { afterEach(function() {
if ($testArea) { if ($testArea) {
...@@ -714,7 +724,7 @@ describe('Knockout Binding', function() { ...@@ -714,7 +724,7 @@ describe('Knockout Binding', function() {
} }
}); });
it('Should update values and options with an observable array', function() { it('Should update values and options with an observable array.', function() {
jasmine.clock().install(); jasmine.clock().install();
$testArea = $('<select multiple="multiple" data-bind="selectedOptions: myValues, options: myOptions, multiselect: {numberDisplayed: 1}"></select>').appendTo(document.body); $testArea = $('<select multiple="multiple" data-bind="selectedOptions: myValues, options: myOptions, multiselect: {numberDisplayed: 1}"></select>').appendTo(document.body);
......
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