Custom event in jQuery that isn't bound to a DOM element?

Viewed 24973

I'm curious if its possible to create a custom event in jQuery that isn't bound to a DOM element.

I greatly prefer jQuery to YUI but there is one thing in YUI that I like, which is creating custom events and being able to subscribe to them later.

For example, this creates an event that is bound to a variable, not to a DOM element:

var myevent = new YAHOO.util.CustomEvent("mycustomevent");

All of the examples and documentation I have been reading for jQuery require something like:

$('body').bind('mycustomevent', function(){
    //do stuff
});
7 Answers

Binding to non-dom elements has been removed in jQuery 1.4.4.

Related