[Phpmyadmin-devel] about AJAX.registerTeardown

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() ? -- Marc Delisle http://infomarc.info

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

Rouslan Placella a écrit :
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.
Yes, it helps. I'll bind also to the .insertRowTable class because the bug is also when editing a table's data. -- Marc Delisle http://infomarc.info
participants (2)
-
Marc Delisle
-
Rouslan Placella