0bc73941fe
Now that the data objects have the `element` property, we can test to make sure it's a DOM element and then use it for selecting the option. This allows us to select multiple options with the same id, as well as handle cases where that is already happening. You cannot use `$e.val()` to select two options with the same id, as jQuery will reject it, but you can set the second option to `.selected = true`, which is supported.
51 lines
1.6 KiB
HTML
51 lines
1.6 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<link rel="stylesheet" href="../vendor/qunit-1.14.0.css" type="text/css" />
|
|
<link rel="stylesheet" href="../../dist/css/select2.css" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="qunit"></div>
|
|
<div id="qunit-fixture">
|
|
<select class="single">
|
|
<option value="default">Default</option>
|
|
<option value="1">One</option>
|
|
<option>2</option>
|
|
</select>
|
|
|
|
<select class="multiple" multiple="multiple">
|
|
<option value="default">Default</option>
|
|
<option value="1">One</option>
|
|
<option>2</option>
|
|
</select>
|
|
|
|
<select class="groups">
|
|
<optgroup label="Test">
|
|
<option value="one">One</option>
|
|
<option value="two">Two</option>
|
|
</optgroup>
|
|
<optgroup label="Empty"></optgroup>
|
|
</select>
|
|
|
|
<select class="duplicates">
|
|
<option value="one">One</option>
|
|
<option value="two">Two</option>
|
|
<option value="one">Uno</option>
|
|
</select>
|
|
|
|
<select class="duplicates-multi" multiple="multiple">
|
|
<option value="one">One</option>
|
|
<option value="two">Two</option>
|
|
<option value="one">Uno</option>
|
|
</select>
|
|
</div>
|
|
|
|
<script src="../vendor/qunit-1.14.0.js" type="text/javascript"></script>
|
|
<script src="../../vendor/almond-0.2.9.js" type="text/javascript"></script>
|
|
<script src="../../vendor/jquery-2.1.0.js" type="text/javascript"></script>
|
|
<script src="../../dist/js/select2.amd.js" type="text/javascript"></script>
|
|
|
|
<script src="select-tests.js" type="text/javascript"></script>
|
|
</body>
|
|
</html>
|