...

View Full Version : Dropdown menu not behaving correctly



Dvx
08-24-2011, 10:50 PM
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:


$(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
08-26-2011, 12:39 AM
Anyone?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum