rniemeyer / knockout-sortable

A Knockout.js binding to connect observableArrays with jQuery UI sortable functionality
MIT License
547 stars 128 forks source link

Any simple comment inside sortable iteration breaks item's bindings after first drag #81

Closed Kasheftin closed 10 years ago

Kasheftin commented 10 years ago

Here I updated Your first sortable example with simple comment tag (it's on the 12'th line) - http://jsfiddle.net/hw9B2/551/. After that, if we drag the bottom item to the top, several items loose their bindings to knockout models.

Here's other example: http://jsfiddle.net/hw9B2/549/. After dragging the bottom item to the top, 3-rd, 4-th and 5-th items loose their bindings (numbers on them hold). If we cut comment tag from the 7-th line, everything works.

rniemeyer commented 10 years ago

This is fixed for anonymous templates. There was logic to strip extra comments/text nodes, but it was modifying the array that was being looped through, so the trailing comments were not actually getting stripped.