This is a migrated thread and some comments may be shown as answers.

Close DropDownList on scroll

1 Answer 342 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Jesse
Top achievements
Rank 1
Jesse asked on 02 Feb 2014, 09:19 PM
I need to be able to close the DropDownList on every page when the user scrolls the page.  Some of my DropDownLists are input controls, some are divs, etc.  Here is my solution; is there a better solution?

(MainContent is the scrolling div that surrounds all the content)

$(function() {
       $('#main-content').on('scroll', function(e) {
           $("*").each(function() {
               var ddl = $(this).data("kendoDropDownList");
               if (ddl) {
                   ddl.close();
               }
           });
});

1 Answer, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 03 Feb 2014, 02:56 PM
Hi Jesse,

I am afraid that there is not a better approach, than iterating iterating through all the Kendo UI DropDownList widgets, and close them using the close() method. A slight optimization might be a more specific jQuery selector, that will only select the DropDownList elements, so you will iterate only them and might not need the if statement then.

Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
DropDownList
Asked by
Jesse
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or