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

Can't get rv-on-click to work in a custom widget #77

Open EB123 opened 7 years ago

EB123 commented 7 years ago

Hi,

I'm having A LOT of difficulties when trying to add "rv-on-click" to my custom widget.

basically I took the list widget and created my own custom widget with the ability to change the color of the value field. This is how my customlist.js looks:

Dashing.widgets.CustomList = function (dashboard) {
    var self = this;
    self.__init__ = Dashing.utils.widgetInit(dashboard, 'customlist');
    self.row = 2;
    self.col = 1;
    self.scope = {};
    self.getWidget = function () {
        return this.__widget__;
    };
    self.getData = function () {};
    self.interval = 10000;
};

rivets.binders['value-color'] = function(el, value) {
        if (value == "Down") {
                $(el).css('color', 'orange');
        }
        else if (value == "OK") {
                $(el).css('color', 'green');
        }
        else if (value == "Error" || value == "FAILED") {
                $(el).css('color', 'red');
        }
};

Now i'm trying to add the following code to the same file ("testbind" is the ID of the customlist div):

var controller = {
        popup: function(el) {
                alert('test');
        }
};

rivets.bind($('#testbind'), {
        controller: controller
});

I've tried like a million different variations, went over every example I could find online, but this doesnt seem to work, i keep getting this "this.call is not a function" error.

What am i missing?

Thanks.