[Phpmyadmin-devel] about AJAX.registerTeardown

Rouslan Placella rouslan at placella.com
Wed Jan 30 18:58:26 CET 2013


On 01/30/2013 01:13 PM, Marc Delisle wrote:
> Hi,
> I am about to add this:
>
> AJAX.registerOnload(
>       'keyhandler.js',
>       function() {
>
>       document.onkeydown = onKeyDownArrowsHandler;
>       function onKeyDownArrowsHandler(e) {
>       ...
>       }
> }
>
> What would be the proper syntax for AJAX.registerTeardown() ?
>

If you do it the jQuery way...

AJAX.registerOnload('keyhandler.js', function() {
   $(document).bind('keydown', function (event) {
     ...
   });
});

...it should become obvious:

AJAX.registerTeardown('keyhandler.js', function() {
   $(document).unbind('keydown');
}

I'm not a big fan of binding to document, it may cause issues if we 
have, or will have, other event handlers attached to it. It's safer to 
bind to an element on the page. You're fixing #3787, right? In that case 
you should be able to bind the event to '#table_columns':

$('#table_columns').bind('keydown', function (event) {
   ...
});

Hope this helps.

Bye,
Rouslan




More information about the Developers mailing list