If you just need the id
values to be unique and don't care if the order of id
values matches the order of the rows, you could use the number of rows to get the next id
value:
$('.add-row').on('click', function (event) {
var newIndex = $('.sort-group').find('.row').length + 1;
function incrementProp(index, prop) {
return prop.replace(/(\d+)/, newIndex);
}
...
You might want to rename incrementProp()
though since its name wouldn't fit anymore.