All docs
V19.2
24.1
The page you are viewing does not exist in version 24.1.
23.2
The page you are viewing does not exist in version 23.2.
23.1
The page you are viewing does not exist in version 23.1.
22.2
The page you are viewing does not exist in version 22.2.
22.1
The page you are viewing does not exist in version 22.1.
21.2
The page you are viewing does not exist in version 21.2.
21.1
The page you are viewing does not exist in version 21.1.
20.2
The page you are viewing does not exist in version 20.2.
20.1
The page you are viewing does not exist in version 20.1.
19.2
19.1
18.2
18.1
17.2
A newer version of this page is available. Switch to the current version.

DevExtreme jQuery - Handle Events

Subscribe to an Event

You can subscribe to an event using a configuration option. All event handling options are given names that begin with on.

JavaScript
$("#menuContainer").dxMenu({
    onItemClick: function (info) {
        // Handles the "itemClick" event
    },
    onSelectionChanged: function (info) {
        // Handles the "selectionChanged" event
    }
});

As a more flexible solution, you can use the on() method. It allows you to subscribe to events at runtime and even to attach several handlers to a single event.

JavaScript
var menuInstance = $("#menuContainer").dxMenu("instance");
// Subscribes to the "itemClick" and "selectionChanged" events
menuInstance
    .on({
        "itemClick": handler1,
        "selectionChanged": handler2
    });
JavaScript
var menuInstance = $("#menuContainer").dxMenu("instance");
// Attaches several handlers to the "itemClick" event
menuInstance
    .on("itemClick", handler1)
    .on("itemClick", handler2);
See Also

Unsubscribe from an Event

To detach a specific handler from an event, call the off(eventName, handler) method.

JavaScript
var menuInstance = $("#menuContainer").dxMenu("instance");
// Detaches the "handler1" from the "itemClick" event leaving other handlers (if any) intact
menuInstance.off("itemClick", handler1)

You can also use this method to detach all handlers from a particular event.

JavaScript
var menuInstance = $("#menuContainer").dxMenu("instance");
// Detaches all handlers from the "itemClick" event
menuInstance.off("itemClick")

If you subscribed to an event using an onEventName option, you can unsubscribe from it by setting this option to undefined.

JavaScript
var menuInstance = $("#menuContainer").dxMenu("instance");
menuInstance.option("onItemClick", undefined);
See Also
  • API Reference.WidgetName.Events, for example, API Reference.Menu.Events