JSFiddle - React, Tailwind, and code Playground

by GregWoods

HTML

<div id="output">Debug<br /></div>

JavaScript

var StaticClass = {
    property1 : "aaa",
    doStuff : function() {
       alert("hello " + this.property1);
    },
    debugLine : function(line) {
        $("#output").html($("#output").html() + line + "<br />");
    },
    eventHandler1 : function(event, eventData) {
        this.debugLine(eventData.eventProperty2);
    }
}

    
//bind the event to the event handler in StaticClass  
$(document).bind("myevent", function(event, eventData) {
    StaticClass.eventHandler1(event, eventData);
});

//code to artificially fire an event
window.setTimeout(function() {
    $(document).trigger("myevent", {
        eventProperty1 : "output",
        eventProperty2 : "greg"
    }); 
}, 1000);