如何保存动态改变的HTML?

发布于 2024-12-06 19:14:23 字数 239 浏览 6 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谈场末日恋爱 2024-12-13 19:14:23

不必费心检查生成的 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.

绅士风度i 2024-12-13 19:14:23

您可以将位置存储在 cookie 中,并在刷新后根据该 cookie 重新排列

you could store the position in a cookie, and rearange after refresh based on that cookie

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文