DevExtreme React - Handle the Value Change Event

To process new TagBox values, you need to handle the value change event. If the handling function is not going to be changed during the lifetime of the widget, assign it to the onValueChanged option when you configure the widget.

JavaScript
$(function() {
    $("#tagBoxContainer").dxTagBox({
        onValueChanged: function (e) {
            var previousValues = e.previousValue;
            var newValues = e.value;
            // Event handling commands go here
        }
    });
});
NOTE
The previousValue and newValue fields are arrays that contain values taken from the valueExpr data field.

If you are going to change event handlers at runtime, or if you need to attach several handlers to the value change event, subscribe to this event using the on(eventName, eventHandler) method.

JavaScript
var valueChangedHandler1 = function (e) {
    var previousValues = e.previousValue;
    var newValues = e.value;
    // First handler of the "valueChanged" event
};

var valueChangedHandler2 = function (e) {
    var previousValues = e.previousValue;
    var newValues = e.value;
    // Second handler of the "valueChanged" event
};

$("#tagBoxContainer").dxTagBox("instance")
    .on('valueChanged', valueChangedHandler1)
    .on('valueChanged', valueChangedHandler2);
See Also