Вопрос

I have a Knockout model that uses the mapping and validation plugins and cannot get it to play nice with Ryan Niemeyer's Knockout sortable plugin - I get the simple error:

Uncaught TypeError: undefined is not a function

The error (which lands on the sortable plugin js), indicates that there is no root element assigned, but I'm not 100% on where this should be set.

When I change "sortable" to "foreach" the model works fine, no errors so I guess something basic is astray.. would very much appreciate any comments.

http://jsfiddle.net/ajson/E23yK/24/

<div data-bind="sortable:Regions">
    <div class="Regionbox">Region:
    <input data-bind="value:Name" /> <a href="#" data-bind="click:     $parent.removeRegion">x</a> 
    </div>
</div>
Это было полезно?

Решение

The knockout-sortable has the following dependencies:

  • Knockout 2.0+
  • jQuery - no specific version identified yet as minimum
  • jQuery UI - no specific version identfied yet as minimum

In your fiddle you are missing jQuery UI so it throws the undefined is not a function exception.

To fix it you just need to include jQuery UI in your code.

Demo JSFiddle.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top