talpor / django-dashing

django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project. Inspired in the dashboard framework Dashing
BSD 3-Clause "New" or "Revised" License
731 stars 108 forks source link

afterRender is not fired after timer #42

Closed asennoussi closed 8 years ago

asennoussi commented 8 years ago

myDashboard.addWidget('AvailabilityAverageWidget', 'Graph', { color: 'steelblue', getData: function () { var self = this; Dashing.utils.get('availability/', function(data) { data.afterRender = function() { alert('graph shown'); }; $.extend(self.data, data); }); }, interval: 60000 });

I have only one alert.

mtdb commented 8 years ago

The idea of afterRender is that only was execute one time, just after the first render, although I have a couple of concerns about your code, first, the first parameter of Dashing.utils.get is the name in snake case of your python widget Class, isn't a route, and the following is that the correct way to bind a afterRender function should be like:

myDashboard.addWidget('AvailabilityAverageWidget', 'Graph', {
    color: 'steelblue',
    scope: {
        afterRender: function() {
            alert('graph shown');
        }
    },
    getData: function () {
        var self = this;
        Dashing.utils.get('availability', function(data) {
            $.extend(self.data, data);
        });
    },
    interval: 60000
});

I just noticed that part of the documentation is outdated, thanks for making me realize this