ProgressOn on Layout


#1

Hello,

I have a layout with some cell and one of them requires many (15 sec) to load because it’s a complex data analisys. So I would like to use the progress on this cell, so it loads the rest of the site.

		function doOnLoad() {
		myLayout = new dhtmlXLayoutObject({
			parent: document.body,
			pattern: "4H"
		});
		myLayout.cells("d").progressOn();
        myLayout.cells("d").setText("Pagamenti");
        myLayout.cells("d").setWidth(440);
		myLayout.cells("d").attachObject("div_pagamenti");		
		myLayout.cells("d").progressOff();

I tried the very simple way, by using ProgressOn and ProgressOff before and after the attachObject, but it didn’t worked :slight_smile:

How can I solve this?


#2

The problem is that progressOff is running as soon as the div is attached, which happens immediately, but that doesn’t mean the div’s content is loaded.

What you need is a way to detect that the content of the div has finished loading. Since the code isn’t here, I don’t know how you’re putting content into the div. The way I’ve done it in the past was to actually have that be a separate page, and use this in place of your last 2 lines:

myLayout.cells("d").attachURL("/path/to/other.page");
myLayout.attachEvent("onContentLoaded",function(id){
    if (id === "d"){
        myLayout.cells("d").progressOff();
    }
});

If you need the div to be part of the current page (or otherwise can’t load it from another page), then you need to find some way to know that the content has finished loading. Either have a setInterval() function that checks for something unique in the content that will only be present when the content has loaded, or if you’re using AJAX calls you can put the progressOff call into the ajax.onreadystatechange() function.

Hopefully this points you in the right direction!


#3

Wow this worked great form me. Obviously I had to make some changes because include a DIV is not exactly the same thing as attach iframe but it worked greatly.

Thank you.