We need the event handler to be attached to document, as forms may loaded via
ajax. So:
Revert "don't attach these event handler on document to prevent the event from bubbling up the whole DOM, which can lead to poor performance"

This reverts commit 9a037a23e9affaff9a6fc2ea0166dbcfd55ea402.
format