jdorn / json-editor

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

Feature request. Clear form without destroy, creation #113

Open wDevil opened 10 years ago

wDevil commented 10 years ago
var reload = function(keep_value) {
        var startval = (jsoneditor && keep_value)? jsoneditor.getValue() : undefined;

        if(jsoneditor) jsoneditor.destroy();
        jsoneditor = new JSONEditor($editor,{
            schema: schema,
            startval: startval
        });

maybe add clear() method?

jdorn commented 10 years ago

The only time you need to destroy and create again is if the schema or any options change. Otherwise, you can just use setValue.

examples/advanced.html has a restore button that I think behaves how you're asking - https://github.com/jdorn/json-editor/blob/master/examples/advanced.html#L99

stefanocudini commented 9 years ago

+1

may be a new reset method is a good idea

stefanocudini commented 9 years ago

@jdorn

using setValue() for reset the form

editor.setValue({})

OR 

editor.setValue('')

OR 

editor.setValue(null)

cause destroy of form :(