Hi.
I have a HAML page that lists some links to delete "things" that looks like this
%div
%a.form_submit Delete Thing 1
%form{:href=>"#", :id=>'comment_1', :method=>'post', :action=>'/thing/delete'}
%input{:type=>'hidden', :name=>'thingid', :value=>'1'}
%input{:type=>'submit', style='display:none'}
%div
%a.form_submit Delete Thing 22
%form{:href=>"#", :id=>'comment_22', :method=>'post', :action=>'/thing/delete'}
%input{:type=>'hidden', :name=>'thingid', :value=>'22'}
%input{:type=>'submit', style='display:none'}
The intention is to have a link "Delete XX" which will delete something specific. A page could have a number of these links, and each link is for a specific "thing".
I also have a piece of (unobtrusive) jQuery javascript that adds a click handler to each form as follows:
$('a.form_submit').click(function(event) {
$('form').submit();
event.preventDefauilt();
});
This works when there is one form on a page. However, if I have more than one form on a page, how do I ensure that clicking "Delete Thing 1" will trigger a submit() event only on the form with id='comment_1'?