JSFiddle - React, Tailwind, and code Playground

by mgrcic

JavaScript

var o = {
    custom: function() {
        alert("o.custom() function called!");    
    }
};

$(o).bind("custom.withNamespace", function(e, data) {
    alert("1: o's custom event fired with data: " + data);
    //e.preventDefault();
    //return false;
});

$(o).bind("custom", function(e, data) {
    alert("2: o's custom event fired with data: " + data);
    //e.preventDefault();
    //return false;
});

// This does what we want
$(o).triggerHandler("custom", ["hello"]);

// This doesn't
$(o).trigger("custom", ["hello"]);