为什么jQuery UI可排序连接列表不能与Angular UI一起使用?

时间:2013-01-26 13:55:33

标签: jquery-ui angularjs jquery-ui-sortable angular-ui

我正在尝试使用Angular UIjQuery UI Sortable来模仿Connected Lists行为。

但是,这种行为非常不稳定:http://jsfiddle.net/hKYWr/227/ 有什么想法吗?


HTML:

<div ng:controller="controller">
    <ul class='mysortable' ui:sortable ui:options="{connectWith:'.mysortable'}" ng:model="list1">
        <li ng:repeat="item in list1" class="item">{{item}}</li>
    </ul>
    <ul class='mysortable' ui:sortable ui:options="{connectWith:'.mysortable'}" ng:model="list2">
        <li ng:repeat="item in list2" class="item">{{item}}</li>
    </ul>
    <hr>
    <pre ng-bind="list1 | json"></pre>
    <hr>
    <pre ng-bind="list2 | json"></pre>
</div>

<script src="http://code.angularjs.org/1.0.2/angular.min.js"></script>
<script src="https://raw.github.com/angular-ui/angular-ui/master/build/angular-ui.min.js"></script>

JS:

var myapp = angular.module('myapp', ['ui']);

myapp.controller('controller', function ($scope) {
    $scope.list1 = ["1", "2", "3"];
    $scope.list2 = ["A", "B", "C"];
});

angular.bootstrap(document, ['myapp']);

CSS:

ul {
    display: inline-block;
}
.item {
    padding: 2px;
    width: 50px;
    height: 20px;
    border: 1px solid #333;
    background: #EEE;
}

3 个答案:

答案 0 :(得分:1)

这将在AngularUI的下一个版本(v0.4.0)中修复

https://github.com/angular-ui/angular-ui/pull/291

答案 1 :(得分:0)

以下是使用默认ui-sortable的示例:http://jsfiddle.net/a9fFC/3但我没有得到模型来反映更新。

但是angular-ui-multi-sortable我得到了它的工作:http://jsfiddle.net/a9fFC/6/

<div ng-controller="controller">
    <ul ui-multi-sortable ng-model="list">
        <li ng-repeat="item in list" class="item">{{item}}</li>
    </ul>
    <hr />
    <div ng-repeat="item in list">{{item}}</div>
</div>

JS:

var myapp = angular.module('myapp', ['ui']);

myapp.controller('controller', function ($scope) {
    $scope.list = ["one", "two", "three", "four", "five", "six"];
});

angular.bootstrap(document, ['myapp']);

答案 2 :(得分:-3)

5比特币说它是角度ui,它是附带影响jquery ui库