icecats11 / js-hotkeys

Automatically exported from code.google.com/p/js-hotkeys
0 stars 0 forks source link

Multiple hotkeys from an Array #33

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi there!

Ok, maybe this not is an issue for the Hotkeys jQuery plugin, but, I am a
bit confused with this and think that someone help me. The question is
this. If you register some hotkeys as usual, that is:

$(d).bind(e, a('a'), function(){r('./post-new.php')});
$(d).bind(e, a('c'), function(){r('./comment-manage.php')});
$(d).bind(e, a('d'), function(){r('./')});

And so on... you are ok, and all work fine that is expected. But, if you
try somthing like this:

var hotkeys = {
  'a' : './post-new.php',
  'c' : './comment-manage.php',
  'd' : './'
}

for(hotkey in hotkeys){
  $(d).bind(e, a(hotkey), function(){r(hotkeys[hotkey])});
}

You obtain that the only hotkey that run is the last in the "hotkeys"
Array. Better said, that hotkeys run (a, c, d) but redirect to the same
URL: the last in the Array, corresponde to "d" hotkey. What happend? Anyone
help me please? Thanks in advance and have anice day! ;-)

Original issue reported on code.google.com by davidesp...@gmail.com on 4 Nov 2008 at 4:36

GoogleCodeExporter commented 8 years ago
It would be much easier for me to deal with your case if I get DHTML.

In general I may say that once you redirect, the rest of the code will never be
executed since the scope of the DOM has vanished. 

Otherwise, the design goal is to execute the whole queue same as it is done in 
other
jQuery event bindings.

Looking forward getting your DHTML.

Original comment by Afro.Sys...@gmail.com on 4 Nov 2008 at 6:54

GoogleCodeExporter commented 8 years ago
Ok, maybe is a problem in my design. In fact, I use some hotkeys in an 
application,
and the point is to show to the user what hotkeys can be used. So, if I have an 
Array
with the hotkeys, I can use this Array for both: register the hotkeys, and show 
to
the user the hotkeys are availables.

Maybe jQuery Hotkeys save a buffer with registered hotkeys? And is accesible? 
In any
case thanks very much for your response. :)

Original comment by davidesp...@gmail.com on 4 Nov 2008 at 5:17

GoogleCodeExporter commented 8 years ago
> Maybe jQuery Hotkeys save a buffer with registered hotkeys? And is accesible? 
look at window.hotkeys.triggersMap

Original comment by Afro.Sys...@gmail.com on 4 Nov 2008 at 7:25

GoogleCodeExporter commented 8 years ago
Ok thanks. I think some better and maybe wrong in my project. However, is a good
point the tip that you show in the last comment. I see for this. Thanks very 
very much!

Original comment by davidesp...@gmail.com on 4 Nov 2008 at 8:37