From 26e979225624c476b5b32c74b66df949f9fb3923 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Sat, 20 Jul 2013 13:41:17 +0000 Subject: [PATCH] Load javascript files before processing other response types, so all JS is available. --- phpgwapi/js/jsapi/egw_json.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/phpgwapi/js/jsapi/egw_json.js b/phpgwapi/js/jsapi/egw_json.js index 2ba940aa31..a02f4fc099 100644 --- a/phpgwapi/js/jsapi/egw_json.js +++ b/phpgwapi/js/jsapi/egw_json.js @@ -95,6 +95,22 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) { json_request.prototype.handleResponse = function(data) { if (data && data.response) { + // Load files first + var js_files = []; + for (var i = data.response.length - 1; i > 0; --i) + { + var res = data.response[i]; + if(res.type == 'js' && typeof res.data == 'string') + { + js_files.unshift(res.data); + data.response.splice(i,1); + } + } + if(js_files.length > 0) + { + this.egw.includeJS(js_files, function() {this.handleResponse(data);}, this); + return; + } for (var i = 0; i < data.response.length; i++) { // Get the response object