Selecting all menu controls with jQuery

4 posts, 0 answers
  1. Andrew
    Andrew avatar
    39 posts
    Member since:
    Feb 2011

    Posted 09 Sep 2011 Link to this post

    My site has the need to close a menu if the mouse leaves the window (its very close to the left edge, so its easily left open).

    As we have multiple menu's on our page, there is the unlikely possibility that more tha none could be left open, so I really wanted to use a jQuery selector to find all menu controls, and fire its close() method when the mouse leaves the window.

    I got to this :



        function () {


    However, the $('.RadMenu').close(); doesn't work - erroring that close() isn't supported. if I go through the results from $('.RadMenu'), they do seem to be the correct elements being returned (HTMLDiv objects).

    Can anyone help?



  2. Andrew
    Andrew avatar
    39 posts
    Member since:
    Feb 2011

    Posted 09 Sep 2011 Link to this post

    It looks like you can't access the object directly, so using another post to get the actual RadMenu object, and iterating through them, this seems to work well...
    var closeAll;
    $telerik.$(document).mouseleave(function () {
        closeAll = setTimeout('closeAllMenus()', 1000);
    function closeAllMenus() {
        var menus = $('.RadMenu').map(function () { return this.control; });
        for (var i = menus.length - 1; i >= 0; i--) {

    The 1000ms delay is because if the menu is still loading up items (ours is populated by a webservice), then you can't close it. The only caveat is that if you move out and in quickly to the window, the menu will still disappear, but its quite a minor thing.
  3. DevCraft R3 2016 release webinar banner
  4. Kate
    Kate avatar
    1898 posts

    Posted 14 Sep 2011 Link to this post

    Hello Andrew,

    Thank you for sharing the solution with us. Let us know if you encounter any further difficulties so we could help you. 

    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
  5. Nona
    Nona avatar
    3 posts
    Member since:
    Jun 2012

    Posted 02 Jul 2012 Link to this post


    Please excuse the shoutout, but I've been looking for this for a week!

    I knew there was a way! 

    the this.control is no where in the documentation. 

Back to Top