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="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/Slider.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" src="src/DAT/GUI/ControllerFunction.js"></script>
<script type="text/javascript"
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/ControllerString.js"></script>
@ -78,7 +80,8 @@
var element;
for (var i = 0; (element = allElements[i]) != null; i++) {
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);
}

View File

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