More robust onError message (see also issue #50)

This commit is contained in:
josdejong 2013-05-28 20:18:51 +02:00
parent f90c9f9fc6
commit d7552b23fa
2 changed files with 3 additions and 4 deletions

View File

@ -197,7 +197,7 @@ JSONEditor.prototype._onError = function(err) {
this.onError(err);
}
if (typeof this.options.error === 'function') {
if (this.options && typeof this.options.error === 'function') {
this.options.error(err);
}
else {

View File

@ -38,10 +38,10 @@ TextEditor.prototype._create = function (container, options, json) {
// read options
options = options || {};
this.options = options;
if (options.indentation) {
this.indentation = Number(options.indentation);
}
this.options = options || {};
this.mode = (options.mode == 'code') ? 'code' : 'text';
if (this.mode == 'code') {
// verify whether Ace editor is available and supported
@ -108,7 +108,6 @@ TextEditor.prototype._create = function (container, options, json) {
catch (err) {
me._onError(err);
}
};
this.content = document.createElement('div');
@ -209,7 +208,7 @@ TextEditor.prototype._onError = function(err) {
this.onError(err);
}
if (typeof this.options.error === 'function') {
if (this.options && typeof this.options.error === 'function') {
this.options.error(err);
}
else {