Fix order of event handlers when declared in html