I am generating a dynamic form
and button
on a handlebars
page.
The original handlebars
code is this:
{{#each record}}
<input class="form-control" type="text" id="comment" value={{comment}}>
<button class="btn small btn-success" id="btn-savecomment">SAVE COMMENT</button>
{{/each}}
and I have a jquery script to save the contents of the form when each button is pressed:
$(document).ready (
function() {
$(document).on('click','#savecomment',function(event){
// save id: comment to record
);
The purpose is to allow the user to type in a comment and then save it to each record.
However how can I ensure the button identifies the right input form when looking the comment? When I click on a particular button it only retrieves the comment from the first record because all of them have identical ids.
Appreciate the help!