Click here to Skip to main content
14,872,753 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello i try to open submenu with focus and then click but the problem is when i try to open other submenu nothink happens its lick click() event works only onces
JavaScript
{

                  if (actTab)
                  {
                      $("#menu > li").eq(b).focus();
                      $("#menu > li").eq(b).click();
                      b++;
                  }
                  else
                  {
                      $('#menu > li').first().focus();
                      $("#menu > li").first().click();
                      actTab = true;
                      b = 1;
                  }




              }


JavaScript
<pre lang="Javascript">

 $(document).ready(function () {
            $.ajax({
                url: 'NavHandler.ashx',
                method: 'get',
                dataType: 'json',
                success: function(data)
                {
                    BuildingMenu($('#menu'), data);
                    $('#menu').menu({
                        position: {
                            my: "center",
                            at: "center",
                            of: "#submenu"
                        }
                       
                    });
                }
            });
            var b;
            var actTab;
            $(window).keydown(function (btn) {
                //down rodykle
                if(btn.which === 40)
                {
                   
                }
                //up rodykle
                else if (btn.which === 38)
                {
                    $("#menu > li").first().collapseAll();
                }
               //right rodykle
                else if(btn.which === 39)
                {
                    
                    if (actTab)
                    {
                        $("#menu > li").eq(b).focus();
                        $("#menu > li").eq(b).click();
                        b++;
                    }
                    else
                    {
                        $('#menu > li').first().focus();
                        $("#menu > li").first().click();
                        actTab = true;
                        b = 1;
                    }
                 
                    
      
                    
                }
                //left rodykle
                else if(btn.which === 37)
                {
                    
                }
            });


            function BuildingMenu(sub,nav)
            {
                $.each(nav, function () {
                    var li = $('<li>' + this.Menutxt + '</li>');
                    li.appendTo(sub);
                    //if(this.List && this.List.lenght > 0)
                    //{
                        var ul = $('<ul></ul>');
                        ul.appendTo(li);
                        BuildingMenu(ul, this.List);
                        
                   // }
                });
                
            }
        });
    </script>



ASP.NET
<pre lang="HTML">
<body>
    <form id="form1" runat="server">
    <%--    <video autoplay loop class="video">
            <source src="NASA- Evidence of flowing water on Mars.mp4" type="video/mp4" />
        </video>--%>
        <div id="wrapper">
           <ul id="menu"> </ul>
            <div id="submenu">

            </div>
        </div>
    </form>
</body>
Posted
Comments
   
Can you please create a jsfiddle demo and tell us the problem clearly?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900