Skip to content

Commit

Permalink
Fixed josdejong#222: editor throwing onChange events when switching…
Browse files Browse the repository at this point in the history
… mode
  • Loading branch information
josdejong committed Jan 12, 2016
1 parent 68e22bb commit c007725
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ https://github.com/josdejong/jsoneditor
- Implemented #183: display a checkbox left from boolean values, so you can
easily switch between true/false.
- Added a minimalist bundle to the `dist` folder, excluding `ace` and `ajv`.
- Fixed #222: editor throwing `onChange` events when switching mode.
- Fixed an error throw when switching to mode "code" via the menu.
- Fixed interfering shortcut keys: changed quick keys to select multiple fields
from `Shift+Arrow Up/Down` to `Ctrl+Shift+Arrow Up/Down`.
Expand Down
6 changes: 0 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ var compilerMinimalist = webpack({
new webpack.IgnorePlugin(new RegExp('^brace$')),
new webpack.IgnorePlugin(new RegExp('^ajv'))
],
//exclude: [
// 'brace',
// 'ajv/dist/ajv.bundle.js'
//],


cache: true
});

Expand Down
6 changes: 6 additions & 0 deletions src/js/textmode.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,13 @@ textmode.setText = function(jsonText) {
this.textarea.value = text;
}
if (this.aceEditor) {
// prevent emitting onChange events while setting new text
var originalOnChange = this.options.onChange;
this.options.onChange = null;

this.aceEditor.setValue(text, -1);

this.options.onChange = originalOnChange;
}

// validate JSON schema
Expand Down
3 changes: 3 additions & 0 deletions test/test_build.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
onError: function (err) {
alert(err.toString());
},
onChange: function () {
console.log('change');
},
indentation: 4,
escapeUnicode: true
};
Expand Down

0 comments on commit c007725

Please sign in to comment.