Mediator
Mediator

Reputation: 15378

How add custom binding to DropDownList

I have binding enterPress

// Custom keypress on ENTER event binding for input elements.
kendo.data.binders.enterPress = kendo.data.Binder.extend({
    init: function (element, bindings, options) {
        kendo.data.Binder.fn.init.call(this, element, bindings, options);
        var binding = this.bindings.enterPress;
        $(element).bind("keypress", function (e) {
            if (e.which == 13) {
                binding.get();
            }
        });
    },
    refresh: function () { }
});

If I use it to DropDownList I have error:

Uncaught Error: The enterPress binding is not supported by the DropDownList widget

How to make enterpress for DropDownList ?

Upvotes: 1

Views: 2714

Answers (2)

John Meyer
John Meyer

Reputation: 2356

You can capture the keydown event of all DropDownList controls using the following code:

kendo.ui.ComboBox.fn._keydown = function(e) {
    if (e.which == 13) {
        alert("key pressed!");
    }
};

Upvotes: 0

Atanas Korchev
Atanas Korchev

Reputation: 30671

Check my reply to your other question:

The kendo.data.binders.widget namespace should be used when creating widget bindings. Widgets are created for elements that have their role data attribute set.

Upvotes: 1

Related Questions