# HG changeset patch # User Torsten Irländer # Date 1370942253 -7200 # Node ID 8525e3525538ff453795a27cbb3cdc58209f0188 # Parent 679dedddb688b839daf5caf8436962b5ad8b658b Move parsing the response in a seperate function. diff -r 679dedddb688 -r 8525e3525538 app/view/widgets/LadaForm.js --- a/app/view/widgets/LadaForm.js Tue Jun 11 09:59:07 2013 +0200 +++ b/app/view/widgets/LadaForm.js Tue Jun 11 11:17:33 2013 +0200 @@ -65,14 +65,12 @@ this.model.save({ callback: function(records, operation) { + this.parseResponse(operation); if (operation.wasSuccessful()) { console.log('Save was successfull'); this.fireEvent('savesuccess', this, records, operation); } else { console.log('Save was not successfull'); - this.errors = this.translateReturnCodes(operation.request.scope.reader.jsonData["errors"]); - this.warnings = this.translateReturnCodes(operation.request.scope.reader.jsonData["warnings"]); - this.message = Lada.getApplication().bundle.getMsg(operation.request.scope.reader.jsonData["message"]); this.form.markInvalid(this.errors); this.fireEvent('savefailure', this, records, operation); } @@ -87,10 +85,12 @@ onModelLoadSuccess: function(record, operation) { this.bindModel(record); + this.parseResponse(operation); this.fireEvent('loadsuccess', this, record, operation); }, onModelLoadFailure: function(record, operation) { + this.parseResponse(operation); this.fireEvent('loadfailure', this, record, operation); }, @@ -100,6 +100,11 @@ translated[k] = Lada.getApplication().bundle.getMsg(codes[k]); } return translated; + }, + parseResponse: function(operation) { + this.errors = this.translateReturnCodes(operation.request.scope.reader.jsonData["errors"]); + this.warnings = this.translateReturnCodes(operation.request.scope.reader.jsonData["warnings"]); + this.message = Lada.getApplication().bundle.getMsg(operation.request.scope.reader.jsonData["message"]); } });