Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Dvx
    Dvx is offline
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dropdown menu not behaving correctly

    Hi

    I have a problem with the javascript menu.

    Currently when you click on the "Login" button then it opens and when you click it again while it is open it closes ands opens again.

    What I want is when you click the login button while it is open then it closes as toggleable button.

    I have posted the javascript to this page: http://jsbin.com/uhefoc/edit#javascript,html,live
    So there it is possible to make realtime updates to the script and see the result real time

    I also posted the script here so not to break the rules:

    Code:
    $(document).ready(function() {
      $("#login-menu a.signin").click(function(event) {
        var link = $(this),
        box = $("fieldset#signin_menu"),
        inputs = $("#signin_menu .form-input input");
    
        event.preventDefault();
    
        link.toggleClass("menu-open");
        box.toggle("signin_menu");
        if(link.hasClass("menu-open")) {
          $("#username").focus();
        } else {
          inputs.val('');
        }
    
        inputs.bind("focus keydown", function(action) {
          if((action.type == "keydown" && action.keyCode == 27) || (action.type == "focus" && !link.hasClass("menu-open")) ) {
            link.trigger("click");
          }
        });
        box.mouseup(function () {
          return false;
        });
        $(document).mouseup(function(what) {
          if($(what.target).parent("a.signin").length == 0 && link.hasClass("menu-open")) {
            link.trigger("click");
          }
        });
      });
    });

  • #2
    Dvx
    Dvx is offline
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Anyone?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •