如何保存动态改变的HTML?
我在 UL LI 列表中排列了大约 8 个 div 项目。每个项目都有唯一的 ID 和特定的内容。这些项目是可排序的,我为此使用 jquery UI。一旦用户拖放列表项的组件位置就会发生变化。但刷新页面后我得到相同的 HTML 页面。我想在服务器上保留项目的新位置。做到这一点的有效方法是什么?我可以创建 HTML 的克隆并在会话期间保留它,但我希望将更改保存在服务器上。元素位置的更改是特定于用户的。这就像用户更改元素位置并且他想要保存设置一样。提前感谢您的帮助
I have around 8 div items arranged in UL LI list. Each has unique ID, and specific content.These items are sortable, I am using jquery UI for this. Once user drag and drop component position of list item changes. But after refreshing the page I am getting same HTML page. I want to retain new positions of items at server. What is the effective way to do this? I can create clone of HTML and retain it during the session but i want changes to be saved at server. The change of position of the element is specific to user.. This is something like element positions are changed by the user and he want to save the settings.. thank for the help in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不必费心检查生成的 HTML。相反,只需通过 AJAX 将新的项目排序传达回服务器即可。这可以像数字序列一样简单。存储这些内容并在下次使用它们以所需的顺序创建列表。
Don't bother inspecting the resulting HTML. Rather, just communicate the new ordering of the items back to the server via AJAX. This could be as simple as a sequence of numbers. Store those and use them next time to create the list in the desired order.
您可以将位置存储在 cookie 中,并在刷新后根据该 cookie 重新排列
you could store the position in a cookie, and rearange after refresh based on that cookie