From 61cab70a4b42d229cffb2efb93b68a79cd15330c Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 3 Jul 2014 20:30:30 +0100 Subject: [PATCH] CRM-14931 - Nicer aja handling of statusBounce errors --- js/crm.ajax.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/crm.ajax.js b/js/crm.ajax.js index 8d785e82c0..5ca6a8907f 100644 --- a/js/crm.ajax.js +++ b/js/crm.ajax.js @@ -213,6 +213,12 @@ this.element.trigger('crmAjaxFail', data); CRM.alert(ts('Unable to reach the server. Please refresh this page in your browser and try again.'), ts('Network Error'), 'error'); }, + _onError: function(data) { + this.element.attr('data-unsaved-changes', 'false').trigger('crmAjaxError', data); + if (this.options.crmForm.autoClose && this.element.data('uiDialog')) { + this.element.dialog('close'); + } + }, _formatUrl: function(url) { // Strip hash url = url.split('#')[0]; @@ -245,10 +251,14 @@ } this.options.block && $('.blockOverlay', this.element).length < 1 && this.element.block(); $.getJSON(url, function(data) { - if (typeof(data) != 'object' || typeof(data.content) != 'string') { + if (!$.isPlainObject(data)) { that._onFailure(data); return; } + if (data.status === 'error') { + that._onError(data); + return; + } data.url = url; that.element.trigger('crmBeforeLoad', data).html(data.content); that._handleOrderLinks(); -- 2.25.1