Forum OpenACS Development: Background loading of includes

Collapse
Posted by Malte Sussdorff on
The project and contact overview pages are written in a modular fashion, breaking them up into a couple of includes which can be moved around and reused somewhere.

One of the drawbacks though is that to build up the page, all includes need to be loaded and only once all includes have been loaded will I be able to see the whole page.

My question now is, is it possible to load the the page with the top two includes open and showing while the rest of them are closed (think of .LRN portlets here. You can show and hide them).

What should ideally happen is that once the user moves with his mouse near the "open" button of a hidden include, the include should be loaded asynchronously so that when the user opens the include (shows / unhide) it will respond fast.

I would also settle for a switch like "load this include all the time, but do it in the background once the main page has been displayed" along with "load this include only if the user says "show"".

Any clue how this can be done? Are the Mashups Solutiongrove has been doing a good way (my main concern here being that I would have a portal page per project, if I understood the code correctly)?

Collapse
Posted by Hamilton Chua on
You will need a front end solution. Here's what I think your project and contact overview pages should be coded.

You'll need to create a page structured with empty divs. Each div is the location of one include.

You should have a javascript function that runs on page load. This javascript function should load the first two includes that you need to be open.

If you consult the ajaxhelper docs, you'll see that ah::ajaxupdate will be able to help you generate the ajax function that loads a url and places the contents of this url into a specified div.

The url you pass to the ajax function should be the url of the include you wish to load.

To load the other includes, you should have an image or any html element with a mouseover event that loads an include.

In the mashup portal, in particular, the code that adds a portlet to the page will be helpful.

I hope this helps.