Skip to content
Milos Stanojevic edited this page Mar 14, 2020 · 2 revisions

Using Supercharge class

Adding events to Supercharge elements is very easy. You can simply create a method with the corresponding name and Supercharge.js will automatically bind the events for you.

class Button extends Supercharge {
    onClick(e) {
        alert('Button clicked!');
    }
}

Using factory

You can do the same using the factory. Simply add a property with the event name and the factory will do the rest.

let app = SuperchargeFactory.build({
    ...
    'onClick': function (e) {
        alert('Mouse Coordinates: ' + e.clientX + ' , ' + e.clientY);
    }
    ...
});
Clone this wiki locally