Ajax refresh a list every 10 seconds ?

lcollong

FabriKant d'applications web
Hi Rob, Hugh and all the Fabrik's expert !

Happy new year and all my best wishes to every Fabrik's lovers !

I've started a huge project in which Fabrik is involved at the server level. The last version has nice new features, specially the new options set at the group level. Great !

Basically, the server of my project collects data in real-time and allow to display, filter and analyse them.

The standby screen (see capture) should ideally be composed with a map showing rising problems (icons), a left highly visible alert sign and the last messages received in a regular text format under the map.

The Fabrik visualization plugin map has an ajax refresh option which does the job very well.

I've used the fabrik list module to display a list in a module underneath the map. How complicated would it be to add an ajax refresh option to this module ?

I've tried to use the custom html module together with the Fabrik content plugin syntax and the standard HTML meta tag "refresh" but it does a whole window refresh which is ugly and uncomfortable !

Since Ajax can be enabled thru the module option pan and it's used for some actions (filters, navigation...) I was wondering if a 10 seconds refresh (reload ?) could be doable ? Something similar to the Gmap Viz options ?

Thanks for any ideas
 

Attachments

  • Capture.JPG
    Capture.JPG
    197.3 KB · Views: 258
any idea ? advice ? suggestion ? it's probably not a common requirement. But how complicated would it be to implement ?
 
You should be able to do this with a simple JS file. You'll need to know the list reference, so in Firefox, in a Firebug console, on the front end page where you list module is, type ...

Fabrik.blocks.

... and it should pop up a list of Fabrik objects on the page, including one for your list module. The list name will include your list ID and the module ID. My test case is list_26_mod_fabrik_list_91.

So, create a file in ./components/com_fabrik/js called 26.js (well, use your list ID). Fabrik will automatically include that file whenever we load list ID 26. In that file, do this:

Code:
function updateList26() {
    if (Fabrik.blocks.list_26_mod_fabrik_list_91) {
        Fabrik.blocks.list_26_mod_fabrik_list_91.submit();
    }
}
var interval = setInterval(updateList26, 10000);

... which just sets up a standard JS interval timer, that fires off the updateList26() function every ten seconds (10000 microseconds). In that function, we just test to see if the module list exists (in case you are displaying list 26 elsewhere, somewhere other than in that module), and if so, fire the submit() method for the list, which is what gets triggered when you navigate or filter it.

I just tested this, and my list in a module with AJAX enabled is happily updating itself every 10 seconds.

-- hugh
 
Hi Hugh,

Almost there !

I've followed your instructions step by step. At the beginning, the js script was fired but the list became white with the spinning wheel running infinitively... So I've suspected the Gmap main module and wanted to try on a basic J page. I've asked the list module to display on all pages instead of only under the map and..... it starts to work !

But, if I setup back the module assignment to "only on the page selected" instead of "on all pages" and if I choose the page displaying the Gmap, I have the infinite wheel....

Any idea ?
 
OK, it's something to do with slimbox, and how it scans the page for images to add it's events to.

I'm attempting to replicate that here, and find the fix.

-- hugh
 
Weird, I can't replicate it here.

Also, i can't login on the backend on the URL you gave me, "Unable to connect to LDAP server".

Can you try switching to Mediabox, in our global params (button top right of Lists page), JS tab? See if that makes any difference.

I think I'll add an option back we used to have in 2.1, to not include a lightbox script at all. Not really a fix, but as you don't have any elements that use images, no reaosn to load it.

-- hugh
 
Congratulations ! It works like a charm. This is really a nice feature for real-time data display. I'll have to find a way to display the new messages in red in order to differentiate them from the older ones but I'll take the time to find out and test.
By the way, the back office password is FabriK (F and K in uppercase). I've just tested it : it works.
Again thanks to Fabrik and thanks to you.
 
Cool. As I said, that isn't really a fix, more of a bandaid. If you've turned lightbox off, then we won't include it anywhere, so you'll no longer have that feature available if you do use things like images as upload elements with thumbs.

BTW, did you try "Use mediabox" so we include the Mediabox JS instead of the original slimbox? I'd be interested in seeing if that blows up in a similar way to the slimbox code.

I can't get either Mediabox or slimbox to fail in the way it does on your site, doing exactly the same thing with a list in a module, either displaying on all pages, or just one.

-- hugh
 
whatever the "use mediabox" switch is, if "include js" is "yes" it does not work. If it set to "no", it works.
As it is a local server with a "quick and dirty" setup, could it be a server side problem in the php version, Apache conf or whatever ? I will copy this test site on a regular hosted one in the following days and I'll keep you informed.
 
Just to keep you inform : it acts the same on an "official server" (shared).
Anyway, it works very well and exactly the way I wish.
I leave it as it is for now ! :)

Thanks
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top