Finding all kendo drop downs on page

jquery, kendo-ui

Solution

The `element` parameter is a DOM object, not a jQuery object, so you'll have to wrap it again; also, you'd need to call `cb.close()` instead of `element.close()` (or bind to `cb`, since you want to add an event handler). You can also simply reference `this` instead of the `element` parameter:

var handler = function (e) {
    console.log("open");
};

$("input").each(function () {
    var cb = $(this).data("kendoDropDownList");
    if (cb) {
        // attach handler to cb
        cb.bind("open", handler)
    }
});

Problem

I'd like to create reusable code to find each kendoDropDown on my page and set an event handler on it. Here's code that finds a single kendoDrop down and does what i want: ``` var cb = $("#myID").data("kendoDropDownList"); console.log("cb: " + cb); if (cb) cb.close(); ``` What I need is code that finds every kendoDropDown on the page and adds the same event handler to each. I've tried ``` $("input").each(function (index, element) { if (element) { var cb = element.data("kendoDropDownList"); if (cb) { console.log("element: " + element); element.close(); } } }); ``` but clearly i'm missing something.

Original source