forked from extern/egroupware
Better handling of doLoadingFinished and firing load event:
- don't fire while still loading - prevent trying to load children before template is actually loaded from file
This commit is contained in:
parent
daf55af475
commit
df660bea3c
@ -77,6 +77,9 @@ var et2_template = et2_DOMWidget.extend(
|
|||||||
|
|
||||||
this.div = document.createElement("div");
|
this.div = document.createElement("div");
|
||||||
|
|
||||||
|
// Flag to indicate that loading is finished
|
||||||
|
this.loading = false;
|
||||||
|
|
||||||
if (this.id != "" || this.options.template)
|
if (this.id != "" || this.options.template)
|
||||||
{
|
{
|
||||||
var template_name = this.options.template || this.id;
|
var template_name = this.options.template || this.id;
|
||||||
@ -105,6 +108,8 @@ var et2_template = et2_DOMWidget.extend(
|
|||||||
|
|
||||||
if(splitted.length)
|
if(splitted.length)
|
||||||
{
|
{
|
||||||
|
// Still loading, don't fire loading finished
|
||||||
|
this.loading = true;
|
||||||
et2_loadXMLFromURL(path, function(_xmldoc) {
|
et2_loadXMLFromURL(path, function(_xmldoc) {
|
||||||
var templates = {};
|
var templates = {};
|
||||||
// Scan for templates and store them
|
// Scan for templates and store them
|
||||||
@ -117,8 +122,17 @@ var et2_template = et2_DOMWidget.extend(
|
|||||||
// Read the XML structure of the requested template
|
// Read the XML structure of the requested template
|
||||||
this.loadFromXML(templates[template_name]);
|
this.loadFromXML(templates[template_name]);
|
||||||
|
|
||||||
// Inform the widget tree that it has been successfully loaded.
|
// Update flag
|
||||||
|
this.loading = false;
|
||||||
|
|
||||||
|
// If the parent is already attached, it has already
|
||||||
|
// finished loading. This template and its children
|
||||||
|
// were left out, so they need processing
|
||||||
|
if(!this.isAttached() && this._parent.isAttached())
|
||||||
|
{
|
||||||
this.loadingFinished();
|
this.loadingFinished();
|
||||||
|
}
|
||||||
|
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -162,8 +176,12 @@ var et2_template = et2_DOMWidget.extend(
|
|||||||
* is loaded asyncronously
|
* is loaded asyncronously
|
||||||
*/
|
*/
|
||||||
doLoadingFinished: function() {
|
doLoadingFinished: function() {
|
||||||
|
if(this.loading) return false;
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
$j(this.getDOMNode()).trigger('load');
|
var self = this;
|
||||||
|
window.setTimeout(function() {
|
||||||
|
$j(self.getDOMNode()).trigger('load');
|
||||||
|
},0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user