2

我正在尝试使用Angular UIjQuery UI Sortable来模仿连接列表的行为。

但是,这种行为非常不稳定: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;
}
4

3 回答 3

1

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

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

于 2013-01-26T17:17:14.747 回答
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']);
于 2013-02-14T16:23:28.537 回答
-3

5 个比特币说它是 angular ui,它间接影响了 jquery ui 库

于 2013-01-26T14:27:37.980 回答