From 444d2b3631102bf3d0662825cc73a6b8df1d8864 Mon Sep 17 00:00:00 2001 From: jos Date: Sat, 16 Apr 2016 12:36:14 +0200 Subject: [PATCH] Fixed enum select boxes not being rendered/removed when setting or removing a JSON schema via `editor.setSchema(schema)` --- HISTORY.md | 6 ++++++ src/js/JSONEditor.js | 10 ++++++++++ src/js/treemode.js | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 669ea6f..43586b1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,12 @@ https://github.com/josdejong/jsoneditor +## not yet released, version 5.5.1 + +- Fixed enum select boxes not being rendered/removed when setting or removing + a JSON schema via `editor.setSchema(schema)`. + + ## 2016-04-16, version 5.5.0 - Implemented a dropdown for values having an JSON Schema enum. diff --git a/src/js/JSONEditor.js b/src/js/JSONEditor.js index eb35df8..7420d49 100644 --- a/src/js/JSONEditor.js +++ b/src/js/JSONEditor.js @@ -297,12 +297,15 @@ JSONEditor.prototype.setSchema = function (schema) { // validate now this.validate(); } + + this.refresh(); // update DOM } else { // remove current schema this.validateSchema = null; this.options.schema = null; this.validate(); // to clear current error messages + this.refresh(); // update DOM } }; @@ -314,6 +317,13 @@ JSONEditor.prototype.validate = function () { // must be implemented by treemode and textmode }; +/** + * Refresh the rendered contents + */ +JSONEditor.prototype.refresh = function () { + // can be implemented by treemode and textmode +}; + /** * Register a plugin with one ore multiple modes for the JSON Editor. * diff --git a/src/js/treemode.js b/src/js/treemode.js index ad215e6..7cc1492 100644 --- a/src/js/treemode.js +++ b/src/js/treemode.js @@ -446,6 +446,15 @@ treemode.validate = function () { }); }; +/** + * Refresh the rendered contents + */ +treemode.refresh = function () { + if (this.node) { + this.node.updateDom({recurse: true}); + } +}; + /** * Start autoscrolling when given mouse position is above the top of the * editor contents, or below the bottom.