1. Fabrik 3.8.1 has been released. It is mostly bug fixes and feature enhancements, but does include two new plugins (push notifications, and the sequence element). As usual we strongly recommend testing the new release on a sandbox if your application is mission critical, and always do an Akeeba backup before updating.
    Dismiss Notice

Dynamic data display on list view (not module).

Discussion in 'Standard Support' started by m6xmed5, Jun 13, 2018.

  1. m6xmed5

    m6xmed5 Member

    Level: Standard
    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.


    Code (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
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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 (Text):

    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
     

Share This Page