You should pass the $event into this handler too, so that you can get the form using $($event.target) instead, and then you can remove the id from the html.