jQuery UI 可排序 php/mysql
我一直在研究一个可排序的列表。我想实现这样的可排序列表: http://jqueryui.com/ demos/sortable/#connect-lists-through-tabs
这是我真正坚持的ajax通信。
我已经设置了一个 jsfiddle http://jsfiddle.net/pnrAx/,显示我当前的代码。 (注意,它是复制和粘贴的,有大量垃圾,需要清理)
字段,更新每行的信息工作正常,没有问题。排序也可以在屏幕上进行,我可以很好地拖放项目。
为了解决这个问题,我如何使用ajax(json?)将页面中排序后的元素放入php页面上的数组中?
从那里,更新表格应该很容易。
I have been working on a sortable list. I want to implement a sortable list like this: http://jqueryui.com/demos/sortable/#connect-lists-through-tabs
It is the ajax communication, that I'm really stuck with.
I have set up a jsfiddle, http://jsfiddle.net/pnrAx/, showing my current code. (Note, it is copy and paste with loads of junk, cleanup needed)
The fields, updating the information on each row are working fine, no problems there. The sorting also works on the screen, I can drag-n-drop items nicely.
To boil the problem down, how can I get the sorted elements from the page, with ajax (json?), into an array on a php page?
From there, it should be pretty easy to update the table.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我要做的是,当你输出时,html将它们放入像这样的数组中
,然后当你发布时,你将有一个“块”的帖子,它将是一个多维数组,
所以在这种情况下,你想要的是一次提交它们并按照它们恢复的顺序处理它们,以便用户排序然后点击提交按钮,表单将按照它们排序的顺序提交所有帖子数据。这有道理吗?
what i would do is when you output then html put them into arrays like this
then when you poste you will have a post of "block" which will be a multi dimensional array
so in this instance what you want is to submit them all at once and process them in the order they are revived so the user would sort then hit a submit button and the form would submit all post data in the the order in which they have sorted them. Does that make sense ?
在 drop 函数中,我将通过 $.ajax 调用 php 页面,并发送刚刚放入查询字符串中的该项目的 ID、新位置和选项卡/类别 ID。然后在新页面上,从数据库获取旧排序位置,并循环遍历删除项目的新位置和旧位置之间的所有项目,递增或递减每个项目的位置。
On the drop function I would call, via $.ajax, a php page and send the ID, new position, and tab/category ID of that item just dropped in the query string. Then on the new page, get the old sort position from the database and loop through all items that are between the new position and old position of the item dropped either incrementing or decrementing the position of each item.