Fixed options method to make sure the initial value is actually selected

This commit is contained in:
George Michael Brower 2011-04-18 17:10:05 -07:00
parent 7de4efc1c1
commit 08eb75861c
2 changed files with 14 additions and 5 deletions

View File

@ -6,13 +6,15 @@
<link href="demo/demo.css" media="screen" rel="stylesheet" type="text/css"/> <link href="demo/demo.css" media="screen" rel="stylesheet" type="text/css"/>
<link href="src/DAT/GUI/gui.css" media="screen" rel="stylesheet" <link href="src/DAT/GUI/gui.css" media="screen" rel="stylesheet"
type="text/css" type="text/css"/>
/>
<script type="text/javascript" src="src/DAT/GUI/GUI.js"></script> <script type="text/javascript" src="src/DAT/GUI/GUI.js"></script>
<script type="text/javascript" src="src/DAT/GUI/Slider.js"></script> <script type="text/javascript" src="src/DAT/GUI/Slider.js"></script>
<script type="text/javascript" src="src/DAT/GUI/Controller.js"></script> <script type="text/javascript" src="src/DAT/GUI/Controller.js"></script>
<script type="text/javascript" src="src/DAT/GUI/ControllerBoolean.js"></script> <script type="text/javascript"
<script type="text/javascript" src="src/DAT/GUI/ControllerFunction.js"></script> src="src/DAT/GUI/ControllerBoolean.js"></script>
<script type="text/javascript"
src="src/DAT/GUI/ControllerFunction.js"></script>
<script type="text/javascript" src="src/DAT/GUI/ControllerNumber.js"></script> <script type="text/javascript" src="src/DAT/GUI/ControllerNumber.js"></script>
<script type="text/javascript" src="src/DAT/GUI/ControllerString.js"></script> <script type="text/javascript" src="src/DAT/GUI/ControllerString.js"></script>
@ -78,7 +80,8 @@
var element; var element;
for (var i = 0; (element = allElements[i]) != null; i++) { for (var i = 0; (element = allElements[i]) != null; i++) {
var elementClass = element.className; var elementClass = element.className;
if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass)) if (elementClass && elementClass.indexOf(className) != -1 &&
hasClassName.test(elementClass))
results.push(element); results.push(element);
} }

View File

@ -76,6 +76,9 @@ DAT.GUI.Controller.prototype.options = function() {
var opt = document.createElement('option'); var opt = document.createElement('option');
opt.innerHTML = i; opt.innerHTML = i;
opt.setAttribute('value', arr[i]); opt.setAttribute('value', arr[i]);
if (arguments[i] == this.getValue()) {
opt.selected = true;
}
select.appendChild(opt); select.appendChild(opt);
} }
} else { } else {
@ -83,6 +86,9 @@ DAT.GUI.Controller.prototype.options = function() {
var opt = document.createElement('option'); var opt = document.createElement('option');
opt.innerHTML = arguments[i]; opt.innerHTML = arguments[i];
opt.setAttribute('value', arguments[i]); opt.setAttribute('value', arguments[i]);
if (arguments[i] == this.getValue()) {
opt.selected = true;
}
select.appendChild(opt); select.appendChild(opt);
} }
} }