I am developing a replacement for the selected menu in jquery.
First I have to set up a new selection menu by simply adding tabindex="0" to the container.
Then I turn off the focus on the original selection menu and give focus to the new one. When the new one focuses and you press the up and down arrows, the parameters change accordingly, but there is a big problem. When you press the arrows, the body also moves.
I tried all these solutions so far no luck:
$(window).unbind('scroll'); $(document).unbind('scroll'); $('body').unbind('scroll'); $(window).unbind('keydown'); $(document).unbind('keydown');
Check out the code here http://pastebin.com/pVNMqyui This code is from the Ideal Forms development version http://code.google.com/p/idealforms , which I will be releasing soon, with keyboard support.
Any ideas why this is not working?
EDIT: Solved!
Found answer to this post disable jquery link tag
var disableScroll = function(e){ if (e.keyCode === 40 || e.keyCode === 38) { e.preventDefault(); return false; } }; // And then... events.focus: function(){ $(window).on('keydown', disableScroll); } events.blur: function(){ $(window).off('keydown', disableScroll); }
It works!
source share