Commit b2fe0312 authored by Boris Kocherov's avatar Boris Kocherov

fix render_selection()

parent 6da36ae6
...@@ -112,7 +112,8 @@ ...@@ -112,7 +112,8 @@
function render_selection(schema, json_document) { function render_selection(schema, json_document) {
var input = document.createElement("select"), var input = document.createElement("select"),
option, option,
option_index; i,
enum_arr = schema['enum'];
input.size = 1; input.size = 1;
if (schema.default) { if (schema.default) {
if (json_document === undefined) { if (json_document === undefined) {
...@@ -122,17 +123,17 @@ ...@@ -122,17 +123,17 @@
option = document.createElement("option"); option = document.createElement("option");
option.value = ""; option.value = "";
if (json_document === undefined) { if (json_document === undefined) {
option.selected = "selected"; option.selected = true;
} }
input.appendChild(option); input.appendChild(option);
} }
for (option_index in schema['enum']) { for (i = 0; i < enum_arr.length; i += 1) {
if (schema['enum'].hasOwnProperty(option_index)) { if (enum_arr.hasOwnProperty(i)) {
option = document.createElement("option"); option = document.createElement("option");
option.value = schema['enum'][option_index]; option.value = enum_arr[i];
option.textContent = schema['enum'][option_index]; option.textContent = enum_arr[i];
if (schema['enum'][option_index] === json_document) { if (enum_arr[i] === json_document) {
option.selected = "selected"; option.selected = true;
} }
input.appendChild(option); input.appendChild(option);
} }
......
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