• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Javascript list plugin (+)

  • Views Views: 17,164
  • Last updated Last updated:

Navigation

  • This plugin attaches Javascript to a button when viewing list data. There will be a button added for each list item and another on the top row to process all items. The Javascript needs to determine which row was clicked via the ids var ids which will be an array of the checked row ids. If you simply click a single button on a row it will be an array of one row id.

    Settings​

    js-options.png

    • Button label - Button label
    • Button image-
    • JavaScript file - File to run, located in plugins/fabrik_list/js/scripts. Set 'statusMsg' to return a status message which will override any static message configured below.
    • JavaScript Code - If no file selected then the Javascript code entered here will be evaluated. Set 'statusMsg' to return a status message which will override any static message configured below.
    • Success message

    Notes​


    A couple of useful variables:​

    console.log(ids); //outputs an array of the selected row ids
    console.log(rows); // outputs a object key'ed on the selected row ids, each value is an object containing the row data.

    Accessing list data​

    You can get at the selected row data by iterating through the 'rows' variable:

    Code:

    jQuery.each(rows, function(rowid, row) {
    // echo the value of yourtable___yourelement to the console
    fconsole(row.yourtable___yourelement);
    })

    You can get at the whole list's data through the list objects 'data' option. First you need to get at the main Fabrik "block" for the list ...

    Code:
    var listdata = Fabrik.getBlock('list_123').Options.data

    ... would get you the main data object (replace 123 with your list's numeric ID).

    That data is then grouped, according to your list's current display grouping, using sequentially numbered indexes starting at 0 for each group.

    If your display is not grouped, it'll all be in listdata[0]. Which is then indexed by row number (not PK value, just the sequential display count, starting at 0). And that then contains another 'data' object, which has all the element values in it. So if you wanted to get the value of 'yourtable___yourelement' in the third row of the first (or only group) ...

    Code:
    var myelement = listdata[0][2] .data.yourtable___yourelement;

    Note that this will give you the "formatted" value, so (for example) if you that element as a detail view link, the above code will give you the data with the A tag round it. If you just want the raw, unformtted data, just append _raw to the element name (yourtable___yourelement_raw).

    And of course you can iterate through the data object, or otherwise do with it what you need to, using standard JS.
Back
Top