jsoneditor/examples/11_autocomplete_basic.html

53 lines
1.2 KiB
HTML
Raw Normal View History

2017-05-26 15:32:01 +08:00
<!DOCTYPE HTML>
<html lang="en">
2017-05-26 15:32:01 +08:00
<head>
<meta charset="utf-8">
2017-05-26 15:32:01 +08:00
<title>JSONEditor | Auto Complete</title>
2017-05-26 15:32:01 +08:00
<link href="../dist/jsoneditor.css" rel="stylesheet" type="text/css">
<script src="../dist/jsoneditor.js"></script>
<style type="text/css">
#jsoneditor {
width: 500px;
height: 500px;
}
p {
width: 500px;
font-family: "DejaVu Sans", sans-serif;
}
</style>
</head>
<body>
<p>
This example demonstrates how to autocomplete works, options available are: 'apple','cranberry','raspberry','pie', 'mango', 'mandarine', 'melon', 'appleton'.
2017-05-26 15:32:01 +08:00
</p>
<div id="jsoneditor"></div>
<script>
// create the editor
const container = document.getElementById('jsoneditor')
const options = {
autocomplete: {
getOptions: function () {
return ['apple', 'cranberry', 'raspberry', 'pie', 'mango', 'mandarine', 'melon', 'appleton'];
2017-05-26 15:32:01 +08:00
}
}
}
const json = {
'array': [{'field1':'v1', 'field2':'v2'}, 2, 3],
'boolean': true,
'null': null,
'number': 123,
'object': {'a': 'b', 'c': 'd'},
'string': 'Hello World'
}
const editor = new JSONEditor(container, options, json)
2017-05-26 15:32:01 +08:00
</script>
</body>
</html>