Custom Knockout JS binding for jQuery UI Sortable

For the work in progress Part 3 of my Editing Variable Length Reorderable Collections in ASP.NET MVC blog series I have created a custom Knockout JS binding that keeps a Knockout JS observable array in sync with a jQuery UI sortable.

It’s available here:

Basic usage is to use a sortableList binding on the ul which you want to make a jQuery Sortable and then a sortableItem binding for each sortable item (li) in the list like that:

<ul data-bind="sortableList: yourObservableArray" >
    {{each(i, arrayItem) yourObservableArray}}
        <li data-bind="sortableItem: arrayItem"></li>
    {{/each}}
</ul>

Live example (if you are reading this in a feed reader you will need to open the blog post properly to see this):

Related Posts:

  1. Custom model binding using IModelBinder in ASP.NET MVC – two gotchas
  2. Editing Variable Length Reorderable Collections in ASP.NET MVC – Part 2: jQuery Templates
  3. Visual Studio 2008 jQuery IntelliSense Fix