0 Star 2 Fork 3

凯旋/jsoneditor

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
05_custom_fields_editable.html 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
<!DOCTYPE HTML>
<html>
<head>
<title>JSONEditor | Custom editable fields</title>
<link href="../dist/jsoneditor.css" rel="stylesheet" type="text/css">
<script src="../dist/jsoneditor.js"></script>
<style type="text/css">
#jsoneditor {
width: 500px;
}
</style>
</head>
<body>
<p>
In this example:
</p>
<ul>
<li>the field <code>_id</code> and its value are read-only</li>
<li>the field <code>name</code> is read-only but has an editable value</li>
<li>the field <code>age</code> and its value are editable</li>
</ul>
<div id="jsoneditor"></div>
<script>
var container = document.getElementById('jsoneditor');
var options = {
onEditable: function (node) {
// node is an object like:
// {
// field: 'FIELD',
// value: 'VALUE',
// path: ['PATH', 'TO', 'NODE']
// }
switch (node.field) {
case '_id':
return false;
case 'name':
return {
field: false,
value: true
};
default:
return true;
}
}
};
var json = {
_id: 123456,
name: 'John',
age: 32
};
var editor = new JSONEditor(container, options, json);
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/cpper-kaixuan/jsoneditor.git
git@gitee.com:cpper-kaixuan/jsoneditor.git
cpper-kaixuan
jsoneditor
jsoneditor
master

搜索帮助