1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script src="../../dist/jsoneditor.js"></script>
</head>
<body>
<textarea class="debug" cols="30" rows="10"></textarea>
<button class='get-value'>Get Value</button>
<div class='container'></div>
<script>
var container = document.querySelector('.container');
var debug = document.querySelector('.debug');
var schema = {
"type": "array",
"title": "Checkboxes",
"items": {
"title": "Checkbox",
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"enum": ["1", "2", "3", "4", "5"]
}
}
};
var editor = new JSONEditor(container, {
schema: schema
});
document.querySelector('.get-value').addEventListener('click', function () {
debug.value = JSON.stringify(editor.getValue());
});
</script>
</body>
</html>
|