0

有谁知道如何使用 ui-sortable 使复选框列表可排序?这是复选框列表:

<div class="controls">
    <label ng-repeat="player in playerlist">
        <input
                type="checkbox"
                name="player.firstname"
                ng-model="player.value"
                > {{player.firstname}}{{player.lastname}}
    </label>
    <!--<pre>{{playerlist| json}}</pre>-->
</div>

我已经尝试(有点乐观)将 ui-sortable 放入标签标签中,但没有运气......

有什么建议么?

干杯,

克苏多

编辑*

抱歉....没有发布示例模型:)

playerlist = [
  {
    "firstname": "Mick",
    "lastname": "McCarthy",
    "_id": "5269409949e375aa0c000005",
    "__v": 0,
    "value": true
  },
  {
    "__v": 0,
    "_id": "5269408f49e375aa0c000004",
    "email": "kseudo@gmail.com",
    "firstname": "Brian",
    "lastname": "Cunningham",
    "phonenumber": 833069486,
    "value": true
  },
  {
    "firstname": "Bill",
    "lastname": "Bops",
    "phonenumber": 23456789,
    "email": "sdfsdf@werewr.iw",
    "_id": "526c011aaa6d6ef40c000003",
    "__v": 0,
    "value": true
  },
  {
    "firstname": "asdf",
    "lastname": "sdf",
    "phonenumber": 234,
    "email": "sdsdf@sdfsdf.ie",
    "_id": "526c01b4aa6d6ef40c000005",
    "__v": 0,
    "value": false
  }
]
4

1 回答 1

1

您应该将 ui-sortable 添加到 div 而不是重复的标签本身。此外,您需要在其旁边包含 ng-model 指令,以便库知道要更新的模型。

<div class="controls" ui-sortable ng-model="playerList">

我还假设您在项目中包含 jQuery 和 jQueryUI。

于 2013-10-26T20:57:29.920 回答