From 65c3f5092346b069e43ad7b3d827d8caf6354ff6 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 13 Feb 2014 15:59:31 +0000 Subject: [PATCH] instanciate app.js object, if not yet done --- etemplate/js/et2_core_common.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/etemplate/js/et2_core_common.js b/etemplate/js/et2_core_common.js index c5b1335e2b..176d3a07d0 100644 --- a/etemplate/js/et2_core_common.js +++ b/etemplate/js/et2_core_common.js @@ -753,8 +753,8 @@ function et2_rangeSubstract(_ar1, _ar2) /** * Call a function specified by it's name (possibly dot separated, eg. "app.myapp.myfunc") * - * @param string func dot-separated function name - * @param arguments variable number of arguments + * @param {string} _func dot-separated function name + * variable number of arguments * @returns {Boolean} */ function et2_call(_func) @@ -767,9 +767,17 @@ function et2_call(_func) { var parts = _func.split('.'); func = parts.pop(); - for(var i=0; i < parts.length && typeof parent[parts[i]] != 'undefined'; ++i) + for(var i=0; i < parts.length; ++i) { - parent = parent[parts[i]]; + if (typeof parent[parts[i]] != 'undefined') + { + 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 window.app.classes[parts[1]] == 'function') + { + parent = parent[parts[1]] = new window.app.classes[parts[1]](); + } } if (typeof parent[func] == 'function') {