I’m using jQuery Sortable and Knockout to maintain an array.
http://jsfiddle.net/daniel_white/KrGY8/3/
Notice when you drag the items, they duplicate or disappear.
Anyone know how I could fix this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
KO’s mapping of items gets a little messed up based on empty text nodes when you are moving things around using jQuery UI sortable.
You can either eliminate the text nodes in your “template” like: http://jsfiddle.net/rniemeyer/KrGY8/5/
Or remove the existing item and put it back to the right spot in two steps (updating the observableArray twice): http://jsfiddle.net/rniemeyer/KrGY8/4/
I also wrote a binding plugin to work with jQuery sortable in Knockout that provides some additional features here: https://github.com/rniemeyer/knockout-sortable