jquery-sortable 使用链表的行为
我怀疑我没有以正确的方式看待这个问题,所以就这样吧。
我本质上在网页上有一个数据的 LinkedList (http://en.wikipedia.org/wiki/ Linked_list),出于性能原因,我想使用传统的链接列表行为进行操作(即仅更新“下一个”对象的引用/id)。
有点棘手的地方是我理想地希望使用 Jquery 的可排序来做到这一点。就像用户向上/向下拖动某些东西一样,我可以使用移动的对象的 id 和该对象的新父 id 对服务器进行 Ajax 调用(然后在幕后我可以弄清楚如何重新连接事物) ..也许需要更多的数据......)。
但是我见过的每个使用可排序的示例都将整个重新索引的列表发送到数据库进行更新,这对我来说似乎没有必要。使用链接列表来更改元素的“索引”,我只需要进行 3 次更新,这取决于列表的大小,这可能会节省很大的性能。有人有我想做的事情的例子吗……我在左外野太远了吗?
I suspect I'm not looking at this issue in the right way so here goes.
I have essentially a LinkedList of data on a web page (http://en.wikipedia.org/wiki/Linked_list) that I'd like to manipulate using traditional Linked List behavior (i.e. just updating the reference/id of the "next" object) for performance reasons.
Where this gets a bit tricky is I'd ideally like to use Jquery's sortable to do this. Like the user would drag something up/down and I could just do an Ajax call to the server with the id of the object that moved and the new parent id of that object (and then behind the scenes I could figure out how to reconnect things..maybe need more data than that...).
But every example I've seen where sortable is used they were sending the whole re-indexed list to the database to update which seems unnecessary to me. With a linked list to change an element's "index" I only need to make 3 updates which depending on the size of the list could be a big performance savings. Anyone have an example of what I'm trying to do...am I too far in left field?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过连接可排序上的“开始”和“更新”事件来解决这个问题,以找出哪个项目已移至何处,然后仅将该索引发送到服务器。
结果用于对存储在服务器上的列表进行重新排序,这在 Python 中很简单:
I solved this by hooking onto the 'start' and 'update' events on sortable to figure out which item had moved to where, and then only sending that index to the server.
The result was used to reorder a list stored on the server, which in Python is as simple as