Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-24-2011, 09:50 PM   PM User | #1
Dvx
New to the CF scene

 
Join Date: Aug 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Dvx is an unknown quantity at this point
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");
      }
    });
  });
});
Dvx is offline   Reply With Quote
Old 08-25-2011, 11:39 PM   PM User | #2
Dvx
New to the CF scene

 
Join Date: Aug 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Dvx is an unknown quantity at this point
Anyone?
Dvx is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:18 AM.


Advertisement
Log in to turn off these ads.