Updated examples

This commit is contained in:
jos 2016-12-26 10:41:07 +01:00
parent f209df27a9
commit c7418807d8
2 changed files with 18 additions and 7 deletions

View File

@ -18,6 +18,10 @@
height: 500px;
margin-right: 24px;
}
code {
background: #e5e5e5;
}
</style>
</head>
<body>
@ -25,7 +29,7 @@
<h1>Synchronize two editors</h1>
<p>
This example demonstrates how to keep two editors synchronized by listening for
the onChange event.
the <code>onPatch</code> event. Other related events are <code>onChange</code> and <code>onChangeText</code>.
</p>
<div id="jsoneditor1"></div>
@ -42,14 +46,14 @@
}
var editor1 = jsoneditor(document.getElementById('jsoneditor1'), {
onChange: function (patch, revert) {
onPatch: function (patch, revert) {
editor2.patch(patch)
}
})
editor1.set(json)
var editor2 = jsoneditor(document.getElementById('jsoneditor2'), {
onChange: function (patch, revert) {
onPatch: function (patch, revert) {
editor1.patch(patch)
}
})

View File

@ -56,13 +56,20 @@
const container = document.getElementById('container')
const options = {
name: 'myObject',
onChange: function (patch, revert) {
console.log('onChange patch=', patch, ', revert=', revert)
onPatch: function (patch, revert) {
console.log('onPatch patch=', patch, ', revert=', revert)
window.patch = patch
window.revert = revert
},
onChangeText: function () {
console.log('onChangeText')
onPatchText: function (patch, revert) {
// FIXME: implement onPatchText
console.log('onPatchText patch=', patch, ', revert=', revert)
},
onChange: function (json) {
console.log('onChange json=', json)
},
onChangeText: function (text) {
console.log('onChangeText', text)
},
onChangeMode: function (mode, prevMode) {
console.log('switched mode from', prevMode, 'to', mode)