jdorn / json-editor

JSON Schema Based Editor
MIT License
5.81k stars 1.08k forks source link

Wisywyg editor does not allow to set values #480

Open Cathbar2 opened 9 years ago

Cathbar2 commented 9 years ago

Hello,

If we use https://github.com/jdorn/json-editor/blob/master/examples/wysiwyg.html

and try and change the example to set a JSON value containing HTML, the JSON editor's HTML field freezes and becomes read-only.

document.getElementById('submit').addEventListener('click', function () {
   editor.setValue({  title: "my test",  body:"<p>\n\Hello\n</p>"     });
});

We have also tried setting the individual field editor, but it only allows to set the value once (the second click on the button is ignored by JSON editor )

document.getElementById('submit').addEventListener('click', function () {
   editor.getEditor('root.body').setValue("<p>\n\Hello\n</p>");
});
Cathbar2 commented 9 years ago

@bcopy : json editor wisywyg issue

brettz9 commented 9 years ago

I've noticed a similar issue in that, while the following will work in wysiwyg.html (placed immediately after setting up the editor):

          editor.setValue({
              title: "Blog Post2",
              body: "<b>hello</b>"
            });

...this will not work (the callback will be executed, but the value setting will cause problems similar to those in the OP--though for me, it is not merely read-only, but I can't see nor manually change any value at all):

editor.on('ready', function () {
          editor.setValue({
              title: "Blog Post2",
              body: "<b>hello</b>"
            });
      });

I haven't been able to figure out what problem the delay is causing.