Skip to content

Version >= 2023/02/17-01

Reload

If, for whatever reason, you have changed the data of the TableView after the initial loading, for example through JavaScript, then you may want to update the TileView afterwards.

Requirements

To be able to reload the TilesView later, you have to create a variable when loading the page and save the created TilesView -object in it. Only if you have such a variable can you call the .reload() method later.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
// file: hooks/TABLENAME-tv.js

let current_tilesview = null; // declare a variable globally

jQuery(function() { // Wait until the table was loaded

    var tile = new AppGiniHelperTVTiles.CardTile();

    var html = '<h5 class="clearfix">' +
        '<span class="label label-default pull-right">id: %_pk%</span>' +
        '</h5>' +
        '<p><small>Typ</small> put placeholders here</p>';

    tile.front.html = html;

    // finally render the Tile View
    current_tilesview = new AppGiniHelperTVTiles.TilesView().render(tile);

});

Reload Tiles View

If you have stored the TilesView -object in an accessible variable, now you can call the .reload() -method

1
current_tilesview.reload();

Attention

Make sure that the variable is available at the point where you want to use it.

The following is not enough, because in this case the variable my_variable is only available within the function, not outside (see 'Scope' in Javascript).

Wrong

1
2
3
4
5
6
7
jQuery(function() {
    // declared locally
    var my_variable = 123;
    // ...
});

// my_variable unknown outside the function

Right

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
// declared globally
var my_variable = null;

jQuery(function() {
    // function called when page has loaded

    // variable is known and can be used
    // even inside the function
    my_variable = 123;
});

// my_variable is known outside the function
// It will be NULL at first
// After the page was loaded, it will be 123