gpt4 book ai didi

javascript - 更新数据对象 ractive.js ractive.sortable.js

转载 作者:行者123 更新时间:2023-12-03 09:41:37 25 4
gpt4 key购买 nike

我正在使用https://github.com/Nijikokun/ractive.sortable.js向表格添加可拖动排序的功能。

 var resources =  [
{
rid: "22222225",
title: "Archive.zip",
filename: "222343.zip",
type: "foo",
duration: "10"
},
{
rid: "22222225",
title: "Archive.zip",
filename: "222343.zip",
type: "foo",
duration: "10"
}
...
]



<tbody id="resourceList" on-sortable='sort-items'>
{{#each resources:num}}
<tr rv-each-item="data.resources">
<td>
<i class="dragHandle glyphicon glyphicon-move">M</i>
</td>
<td class="rTitle">{{title}}</td>
<td class="rType">{{filename}}</td>
<td class="rType">{{type}}</td>
<td class="rDuration">
{{#if duration}}
<input type="number" min="10" step="1" value="{{duration}}"> seconds
{{/if}}
</td>
<td>
{{#if resources.length != 1 }}
<button class="btn" type="button" on-click='removeItem'><i class="deleteRow glyphicon glyphicon-trash"></i>
</button>
{{/if}}
</td>
</tr>
{{/each}}
</tbody>

拖动按预期工作 - 我只是很难弄清楚如何提取新的排序顺序,并使用它来更新数据数组中对象的顺序。我一直在玩 ractive.observe - 但无法理解它......

最佳答案

您不需要以任何方式更新数组。可排序插件将为您做到这一点。

关于javascript - 更新数据对象 ractive.js ractive.sortable.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31166516/

25 4 0