Dynamic data display on list view (not module).

m6xmed5

Member
I have been looking around the forums to see if it's possible to have the data display dynamically, so as someone submits or edits a form the list view updates for everyone viewing it without a page refresh.

I read that we can do an ajax refresh as long as ajax is turned on in the list options.

So I created a file in components/com_fabrik/js called list78.js with the following code in it.


JavaScript:
requirejs(['fab/fabrik'], function () {
       Fabrik.addEvent('fabrik.list.submit.ajax.complete', function(list, data) {


           function updateList78() {
                if (Fabrik.blocks.list_78) {
                Fabrik.blocks.list_78.submit();
    }
}
var interval = setInterval(updateList78, 10000);

  
});
});

I have also set mediabox instead of slimbox on the global js options.
It does nothing, anyone any ideas what I'm doing wrong? I'm know the list78.js file is included because one of the times I was messing about with the addEvent it threw an error referencing that file.

Any help is much appreciated.

Marc
 
Well, your update will only run on a fabrik.list.submit.ajax.complete. That second line says "run my code when the fabrik.list.submit.ajax.complete is fired. Which gets fired after someone does something that causes an AJAX refresh (navigation, filtering, etc).

If you just want to reload every 10 seconds

Code:
requirejs(['fab/fabrik'],function(){
   Fabrik.addEvent('fabrik.list.loaded', function(list) {
      list.updateRows.periodical(10000, list);
   });
});

... which waits till your list is loaded, then adds a periodical to fire the updateRows() method for that list every 10 seconds.

if you have more than one list on the page, you'd need to add a check to make sure you only add the periodical for the right list ID.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top