If I understand this correctly, then you could probably use the $index
observable that is available when binding in a foreach
.
So, you would bind something like:
<table style="width : 100%" data-bind="attr: { id: 'field-nr-' + $index() }" >
As you drag the fields around, the id will remain updated based on its position in the observableArray.
I updated your fiddle (and updated the KO version) to show the the value in a td
: http://jsfiddle.net/rniemeyer/56PLd/