I have form in jsp with spring:bind for the input element:
<table id="tab_logic">
<thead></thead>
<tbody>
<tr id='addr0'>
<td>
<spring:bind path="createForm.contractEntitlements[0].entitledQuantity">
<form:input type="number" min="0" max="999" name="entitled_quantity" id="entitled_quantity" path="${status.expression}"/>
</spring:bind>
</td>
</tr>
<tr id='addr1'></tr>
</tbody>
</table>
<input type="button" id="add_row" value="show" />
<input type="button" id="delete_row" value="hide" />
I need it to be dyanmic so I added a button to add/delete a row and call the script when clicked. For testing to see whether it will add or not I just used as a tag:
$(document).ready(function(){
var i=1;
$("#add_row").click(function(){
$('#addr'+i).html("<td>"+ (i+1) +"</td><td><input name='"+i+"' type='text' /></td>");
$('#tab_logic').append('<tr id="addr'+(i+1)+'"></tr>');
i++;
});
$("#delete_row").click(function(){
if(i>1){
$("#addr"+(i-1)).html('');
i--;
}
});
});
it adds and delete the rows accordingly but when I change the line to :
$('#addr'+i).html("<td>"+ (i+1) +"</td><td><form:input name='"+i+"' type='text' path='createForm.contractEntitlements[1].category' /></td>");
nothing happens when I click the button, no error on the logs. Does spring binding happens when the page loads and can't bind anymore or I'm doing it wrong?