jQuery UI sortable 返回 ul,但我真正想要的是两个 li
我使用 jQuery UI sortable 允许用户随机播放列表,但停止事件返回整个列表。
所以我处理:
$(this).children('li').each(function(index) {
但我真正想做的是只处理受影响的范围。我想我需要的是:正在拖动的列表项,以及它放置在之前(或之后,以方便者为准)的列表项。这样我就可以更新受影响的列表中的范围,而不必更新整个列表。
也许我应该继续向每个列表项添加一个 data-Counter 属性,看看它们是否与索引不同。
I'm using jQuery UI sortable to allow the user to shuffle the list, but the stop event returns the entire list.
So I process:
$(this).children('li').each(function(index) {
But what I really want to do is process only the range that's affected. I suppose what I need is: the list item that is being dragged, and the list item that it is being placed before (or after, which ever is convenient). That way I can update the range within the list that is being affected, and not have to update the entire list.
Maybe I should just keep add a data-Counter attribute to each list item and see if they are different from the index.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在拖动开始时保存项目的开始位置,您可以轻松解决这个问题。
试试我的演示:http://jsfiddle.net/b8uJ8/
You can easily work it out if you save the item's start position when dragging starts.
Try my demo: http://jsfiddle.net/b8uJ8/