Jquery 可拖动的订单

Jquery 可拖动的订单,jquery,angularjs,Jquery,Angularjs,这个例子: 项目{$index}和顺序:{{order}? 这将产生: <li> item 1 and order 1 </li> <li> item 2 and order 2 </li> <li> item 3 and order 3 </li> 项目1和订单1 项目2和订单2 项目3和订单3 但是如果我首先更改第三个,我将更改项目3和订单1,我需要更新中的所有订单 <li> item 3 an

这个例子:

  • 项目{$index}和顺序:{{order}?
这将产生:

<li> item 1 and order 1 </li>
<li> item 2 and order 2 </li>
<li> item 3 and order 3 </li>
  • 项目1和订单1
  • 项目2和订单2
  • 项目3和订单3
  • 但是如果我首先更改第三个
  • ,我将更改项目3和订单1,我需要更新
  • 中的所有订单

    <li> item 3 and order 1 </li>
    <li> item 1 and order 2 </li>
    <li> item 2 and order 3 </li>
    
  • 项目3和订单1
  • 项目1和订单2
  • 项目2和订单3

  • 有什么建议吗?

    您需要在ng reapeat字段中按索引指定曲目。如果您添加以下代码并重试

    <ul id="sortable" ng-repeat="x in listValue track by $index"">
      <li class="ui-state-default">
       <span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
       Item {{$index}} and order : ¿ {{order}} ?
      </li>
    </ul>
    

    尝试将Angular UI Sortable与JQuery UI一起使用
    在HTML中:

    <ul class="list" ng-model="table1" ui-sortable="sortableOptions">
        <li class="item" ng-repeat="p in table1">{{ p.name }} and order {{p.order}}</li>
    </ul>
    

    您可以获得Sortable.js。这是一个我相信可以实现你想要的。希望这有帮助。祝你好运

    不明白你在问什么。“如果我先换第三个
  • ”。请更好地解释您的问题。@Rani Radcliff i update Post问题不是索引,我需要在移动的“li”时更新“order”值posicion@sirdaiz,试试这个$scope.listValue=[];首先,您需要获得可更改项目的副本。然后,使用$scope.listValue.splice(index3,1,1stObj)进行更新时,var 1stObj=listValue[1]var 3rdObj=listValue[3]$范围列表值拼接(index1,1,3rdObj);如果我有100个,我就不能说我有100个。。。var 100rdobjGetTime函数中有什么?我正试图帮助您,但考虑到您提供的代码数量有限,这是很困难的。我试着在一个Plunker中测试你的代码,但似乎无法让“可排序”与ng repeat一起工作。我不熟悉jQueryUI。如果你能让这两个人一起工作,我可以帮你解决你的问题。我喜欢这个,让我稍后再试,我会告诉你的,谢谢
    <ul class="list" ng-model="table1" ui-sortable="sortableOptions">
        <li class="item" ng-repeat="p in table1">{{ p.name }} and order {{p.order}}</li>
    </ul>
    
     $scope.table1 = [
        {
            id: 1,
            name: 'Item 1',
            order: 1
        },
        {
            id: 2,
            name: 'Item 2',
            order: 2
        },
        {
            id: 3,
            name: 'Data3',
            order: 3
        },
        {
            id: 4,
            name: 'Data4',
            order: 4
        },
        {
            id: 5,
            name: 'Data5',
            order: 5
        }
    ];
    $scope.sortableOptions = {
        stop: function (e, ui) {
            for (var index in $scope.table1) {
                $scope.table1[index].order = Number(index) + 1;
    
            }
    
    
        }
    };