A bit difficult to explain this, but I have a lot of elements in my application, most pages have tabs, and there are an average of 6 tabs per page, each tab may have 20 elements many of which will be comboboxes, dateboxes etc etc.
It can take as much as 30 seconds for all of the associated hidden panels for comboboxes etc to be generated in the DOM, this is making the application very sluggish.
So I have been experimenting with fragments (HTML5 templates) by only loading the first visible tab, and the rest of the tabs are only rendered when the tab is selected and the fragment is activated on demand.
This works if the element has all of it's data options set in the html code as data-options='', however it idoes not work if the element's attributes, events etc are defined in a javascript which is pre-loaded initially.
It is just not practical to define all of the events using HTML as some are very complex, and this means that those elements that have their definitions loaded when the page initially loads, are not enabbled when the fragment is activated and the element is parsed using $.parser.parse().
I guess what I am looking for is something like this that will wait for the element to be added:
<div id="mydiv" />
function live(elid,cname,options){
$(document).bind('DOMNodeInserted',function(e) {
if(e.target.id==elid) {
e.target.className = cname;
for(var k in options){
$(e).textbox('options')[k] = options[k];
}
}
});
}
live('xx','easyui-textbox',{
value:'xxxx',
onChange: function(nv,ov){
console.log(nv)
}
});
setTimeout(function(){
$('#mydiv').append($('<input id="xx" />'));
}, 2000)
can this be done ? - actually what i want to do is for the element to get it's pre-defined javascript attributes that were loaded with the page.
If easyui elements had a defer property and render() method, whereby they would be loaded to the DOM, but would not render or execute any code until the render(0 method was called, this would mean that it could be done without fragments ?