Skip to content

Commit

Permalink
recursive load of components
Browse files Browse the repository at this point in the history
  • Loading branch information
Quickcorp committed May 8, 2018
1 parent a52ef5a commit ea58f7a
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions QCObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,18 +859,28 @@
* Load every component tag declared in the body
**/
Ready(function (){
var components = document.querySelectorAll('component');
for (var _c = 0;_c<components.length;_c++){
Class('ComponentBody',Component,{
'name':components[_c].getAttribute('name').toString(),
'reload':true
});
var newComponent = New(ComponentBody,{
'name':components[_c].getAttribute('name').toString(),
'templateURI':'{{COMPONENTS_BASE_PATH}}{{COMPONENT_NAME}}.html'.replace('{{COMPONENT_NAME}}',components[_c].getAttribute('name').toString()).replace('{{COMPONENTS_BASE_PATH}}',CONFIG.get('componentsBasePath'))
});
components[_c].append(newComponent);
}
var _buildComponent = function (components){
for (var _c = 0;_c<components.length;_c++){
Class('ComponentBody',Component,{
'name':components[_c].getAttribute('name').toString(),
'reload':true
});
var newComponent = New(ComponentBody,{
'name':components[_c].getAttribute('name').toString(),
'templateURI':'{{COMPONENTS_BASE_PATH}}{{COMPONENT_NAME}}.html'.replace('{{COMPONENT_NAME}}',components[_c].getAttribute('name').toString()).replace('{{COMPONENTS_BASE_PATH}}',CONFIG.get('componentsBasePath'))
});
newComponent.done = function (){
_buildComponent(this.body.querySelectorAll('component'));
};
components[_c].append(newComponent);
components[_c].setAttribute('loaded',true);
}
};
var components = document.querySelectorAll('component:not([loaded])');
while (components.length>0){
_buildComponent(components);
components = document.querySelectorAll('component:not([loaded])');
}
});

/*
Expand Down

0 comments on commit ea58f7a

Please sign in to comment.