AnitaTang / js-hotkeys

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

ajax loading/same target name -> cannot apply hotkey #6

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
imo the storing of elements needs to be enhanced, so that objects as
targets and objects+ajax loading can work

//small fix
//so we can have multiple form callbacks - on the same form(ajax loaded...)
this.toString=function(){
                    if(!this.random_name)this.random_name=Math.round(Math.random()*1000);
return 'Form: '+this.random_name+$(this).attr('action');
                }

Original issue reported on code.google.com by grosser....@gmail.com on 25 Sep 2007 at 1:39

GoogleCodeExporter commented 8 years ago
I am afraid I didn't understand what problem you are trying to solve.
Please explained how ajax and js-hotkeys conflicting one another at current 
version.

Original comment by Afro.Sys...@gmail.com on 1 Oct 2007 at 3:48

GoogleCodeExporter commented 8 years ago
when i add two hotkeys on form tags
...add(target:$('#one form'))
...add(target:$('#two form'))
they will not work since both have the same toString method, which is what ur 
using
when storing them "if (!this.all[opt.target].events[opt.type]){"
so to make them work they have to have different toString, 'Form:
+$(this).attr('action')' but when ajax-loading a form (#one form) and adding the
hotkey again this will be the same again(old #one form overlapping new #one 
form) so
only return 'Form: '+this.random_name+$(this).attr('action') will work.

Original comment by grosser....@gmail.com on 2 Oct 2007 at 7:03

GoogleCodeExporter commented 8 years ago
Is this possibly related to the problem I am having :
I have a JSON object with key, text pairs. I iterate through, but for all 
hotkeys I 
get the text for the last hotkey added:

for(i=0;i < hotkeys.length; i++)
{
            var key = hotkeys[i].key;
            var text = hotkeys[i].text;

            $.hotkeys.add(key, function(){DoStuff(text);});
        }    

Original comment by yuvaa...@gmail.com on 25 Feb 2008 at 2:36

GoogleCodeExporter commented 8 years ago
Apologies for comment 3 (I'm new to js). I need to use new Function , and 
everything 
works perfectly now.

Original comment by yuvaa...@gmail.com on 26 Feb 2008 at 7:07

GoogleCodeExporter commented 8 years ago
you should use the jQuery each. Avoid for loops in jQuery. Weird things 
happen...
That is the same reason why test.html bombs.

Original comment by rodni...@gmail.com on 27 Feb 2008 at 12:01

GoogleCodeExporter commented 8 years ago

Original comment by Afro.Sys...@gmail.com on 24 Aug 2008 at 8:48