class method

View source on GitHub →, eventName[, memo[, bubble = true]]) → Event


Fires a custom event with the current element as its target. creates a custom event with the given name, then triggers it on the given element. The custom event has all the same properties and methods of native events. Like a native event, it will bubble up through the DOM unless its propagation is explicitly stopped.

The optional second argument will be assigned to the memo property of the event object so that it can be read by event handlers.

Custom events are dispatched synchronously: waits until the event finishes its life cycle, then returns the event itself.

Note does not support firing native events. All custom event names must be namespaced (using a colon). This is to avoid custom event names conflicting with non-standard native DOM events such as mousewheel and DOMMouseScroll.

document.observe("widget:frobbed", function(event) {
  console.log("Element with ID (" + +
   ") frobbed widget #" + event.memo.widgetNumber + ".");
 var someNode = $('foo');"widget:frobbed", { widgetNumber: 19 });
 //-> "Element with ID (foo) frobbed widget #19."

Events that have been stopped with Event.stop will have a boolean stopped property set to true. Since returns the custom event, you can inspect this property to determine whether the event was stopped.

This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.