maheshchari / js-hotkeys

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

Fix for binding and unbinding problems. #87

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
0. function cb(e){alert(String.fromCharCode(e.which)+' pressed')};
1. $(document).bind('keydown', '1', cb);
2. $(document).bind('keydown', '2', cb);

What is the expected output? What do you see instead?
When pressing "1" or "2", a single alert box should be seen. 
Instead, two alert boxes are popped up. 

What version of the product are you using? On what operating system?
.7.9

Please provide any additional information below.
The problem is that binds to for the event type that have previously been bound 
rebind that event type causing callbacks to be called multiple times. 

A similar problem occurs on unbinds. An unbind will unbind all the callbacks 
for a particular event-type. 

I've fixed the problem in the attached file.

The test.html file is to test.

Original issue reported on code.google.com by dpa...@gmail.com on 22 Jun 2010 at 5:38

Attachments:

GoogleCodeExporter commented 8 years ago
Here is the diff file:
87c87
<         return  this.__unbind__(type, fn);
---
>         else return  this.__unbind__(type, fn);
153c153,155
<                     result = this.__bind__(handle.join(' '), data, 
hotkeys.handler)
---
>           var handles=handle.join(' ');
>           this.__unbind__(handles, hotkeys.handler);
>                     result = this.__bind__(handles, data, hotkeys.handler);
245d246
< 

Original comment by dpa...@gmail.com on 22 Jun 2010 at 5:44

Attachments: