mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-27 00:09:13 +01:00
Wait until DOM is loaded before trying to load etemplate or set message
This commit is contained in:
parent
8c44986e7b
commit
15bc1b3909
@ -40,6 +40,7 @@
|
|||||||
var debug = false;
|
var debug = false;
|
||||||
var egw_script = document.getElementById('egw_script_id');
|
var egw_script = document.getElementById('egw_script_id');
|
||||||
var start_time = (new Date).getTime();
|
var start_time = (new Date).getTime();
|
||||||
|
if(console.timeline) console.timeline("egw");
|
||||||
|
|
||||||
// Flag for if this is opened in a popup
|
// Flag for if this is opened in a popup
|
||||||
var popup = (window.opener != null);
|
var popup = (window.opener != null);
|
||||||
@ -155,6 +156,7 @@
|
|||||||
|
|
||||||
window.egw_LAB.script(include).wait(function()
|
window.egw_LAB.script(include).wait(function()
|
||||||
{
|
{
|
||||||
|
if(console.timelineEnd) console.timelineEnd("egw");
|
||||||
var end_time = (new Date).getTime();
|
var end_time = (new Date).getTime();
|
||||||
var gen_time_div = $j('#divGenTime_'+window.egw_appName);
|
var gen_time_div = $j('#divGenTime_'+window.egw_appName);
|
||||||
if (!gen_time_div.length) gen_time_div = $j('.pageGenTime');
|
if (!gen_time_div.length) gen_time_div = $j('.pageGenTime');
|
||||||
@ -187,7 +189,6 @@
|
|||||||
var data = egw_script.getAttribute('data-etemplate');
|
var data = egw_script.getAttribute('data-etemplate');
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
data = JSON.parse(data) || {};
|
|
||||||
// Initialize application js
|
// Initialize application js
|
||||||
var callback = null;
|
var callback = null;
|
||||||
// Only initialize once
|
// Only initialize once
|
||||||
@ -199,6 +200,10 @@
|
|||||||
{
|
{
|
||||||
egw.debug("warn", "Did not load '%s' JS object",window.egw_appName);
|
egw.debug("warn", "Did not load '%s' JS object",window.egw_appName);
|
||||||
}
|
}
|
||||||
|
// Wait until DOM loaded before we load the etemplate to make sure the target is there
|
||||||
|
$j(function() {
|
||||||
|
// Re-load data here, as later code may change the variable
|
||||||
|
var data = JSON.parse(egw_script.getAttribute('data-etemplate')) || {};
|
||||||
var node = document.getElementById(data.DOMNodeID);
|
var node = document.getElementById(data.DOMNodeID);
|
||||||
if(!node)
|
if(!node)
|
||||||
{
|
{
|
||||||
@ -216,7 +221,9 @@
|
|||||||
var et2 = new etemplate2(node, window.egw_appName+".etemplate_new.ajax_process_content.etemplate");
|
var et2 = new etemplate2(node, window.egw_appName+".etemplate_new.ajax_process_content.etemplate");
|
||||||
et2.load(data.name,data.url,data.data,callback);
|
et2.load(data.name,data.url,data.data,callback);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
$j(function() {
|
||||||
// set app-header
|
// set app-header
|
||||||
if (window.framework && (data = egw_script.getAttribute('data-app-header')))
|
if (window.framework && (data = egw_script.getAttribute('data-app-header')))
|
||||||
{
|
{
|
||||||
@ -228,6 +235,7 @@
|
|||||||
window.egw_message.apply(window, data);
|
window.egw_message.apply(window, data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user