On Wed, Dec 17, 2008 at 4:05 PM, brian <bally.z...@gmail.com> wrote:
> On Wed, Dec 17, 2008 at 2:31 PM, sshefer <shai.she...@gmail.com> wrote:
>>
>> Here is my current code:
>>
>>        $('.position_info').hover(
>>          function(e) {
>>                var target = $(e.target);
>>            target.bind('keydown', 'space', function(){
>>                  target.children('strong').toggle();
>>                });
>>          },
>>          function(e) {
>>                var target = $(e.target);
>>                target.unbind('keydown', 'space');
>>          }
>>        );
>>
>
> the target.bind('keydown', 'space', ... won't work because you have to
> pass an object. Similarly, unbind() takes an event type and a
> function. You'll need to figure out which key has been pressed in your
> handler function.
>
> I'd do something more like this (yeah, I tested it and it doesn't work
> but, anyway ...)
>
> $('.position_info').hover(
>        function(e)
>        {
>                var target = $(e.target);
>                target.bind(
>                        'keydown',
>                        {combi:'space', disableinInput: true},
>                        handler
>                );
>        },
>        function(e)
>        {
>                var target = $(e.target);
>                target.unbind('keydown');
>        }
> );
>
> function handler(e)
> {
>        var target = $(e.target);
>        target.children('strong').toggle();
>        alert(e.data.combi);
> }
>
> Good luck.
>

One thing I just thought of: you probably need to give the target
focus because it won't ordinarily get that onHover and the keydown
event might not be caught unless it has focus, first.

target.focus();

Add this to your page to ensure that, at least, is working:

$('.position_info').focus(function(e){ var target = $(e.target);
target.css('background', 'yellow'); });

Reply via email to