check if json apply needs a not yet instanciated app.js object and instanciate it in that case

This commit is contained in:
Ralf Becker 2014-01-23 09:03:30 +00:00
parent 653f013975
commit a788827c1e
2 changed files with 38 additions and 24 deletions

View File

@ -485,6 +485,12 @@ egw_json_request.prototype.handleResponse = function(data, textStatus, XMLHttpRe
{ {
var parts = res.data.func.split("."); var parts = res.data.func.split(".");
// check if we need a not yet instanciated app.js object --> instanciate it now
if (parts.length == 3 && typeof window.app[parts[1]] == 'undefined' &&
typeof window.app.classes[parts[1]] == 'function')
{
window.app[parts[1]] = new window.app.classes[parts[1]]();
}
if(parts.length == 3 && typeof window.app[parts[1]] == "object" && if(parts.length == 3 && typeof window.app[parts[1]] == "object" &&
typeof window.app[parts[1]][parts[2]] == "function") typeof window.app[parts[1]][parts[2]] == "function")
{ {

View File

@ -332,10 +332,18 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
var parts = res.data.func.split('.'); var parts = res.data.func.split('.');
var func = parts.pop(); var func = parts.pop();
var parent = req.egw.window; var parent = req.egw.window;
for(var i=0; i < parts.length && typeof parent[parts[i]] != 'undefined'; ++i) for(var i=0; i < parts.length; ++i)
{
if (typeof parent[parts[i]] != 'undefined')
{ {
parent = parent[parts[i]]; parent = parent[parts[i]];
} }
// check if we need a not yet instanciated app.js object --> instanciate it now
else if (i == 1 && parts[0] == 'app' && typeof req.egw.window.app.classes[parts[1]] == 'function')
{
parent = parent[parts[1]] = new req.egw.window.app.classes[parts[1]]();
}
}
if (typeof parent[func] == 'function') if (typeof parent[func] == 'function')
{ {
try try