关于将元素保存到 DOM 和选项卡的 jQuery 问题
我正在开发一个项目,并且正在使用 jQuery 选项卡,如下图所示。我安装了一个内联编辑脚本来修改文本,并根据需要删除。此时不涉及数据库,我有一个 VIN 解码器脚本,它提取默认功能,如果需要,他们可以对其进行编辑,并且它在 DOM 中进行编辑。它工作得很好,但是当我将选项卡切换到“内部”,然后返回“外部”时,外部内容将返回到原始列表,并且不会保存任何更新。
这可能是因为主页位于 add-vehicle.php ,在该页面上,这就是我获取内容的方式:
<div id="tabContent">
<div id="contentHolder">
<!-- The AJAX fetched content goes here -->
</div>
</div>
并且内容位于 features.php
< img src="https://i.sstatic.net/hPh2J.jpg" alt="在此处输入图像描述">
var Tabs = {
'Mechanical' : 'features.php?feature=MECHANICAL&vin='+vin+'',
'Exterior' : 'features.php?feature=EXTERIOR&vin='+vin+'',
'Interior' : 'features.php?feature=INTERIOR&vin='+vin+'',
'Safety' : 'features.php?feature=SAFETY&vin='+vin+'',
}
有人对我如何执行此操作有任何建议吗?我想要发生的是所有内联编辑都将被保存,并且我可以切换不同的选项卡并进行这些更改,并且所有内容都将被保存。
不确定我解释得如何,如果您需要查看更多代码,请告诉我。
谢谢
I am working on a project and I am using jQuery Tabs like the image below. I installed an Inline Edit script to modify the text, and delete if needed. There is no database involved at this point, I have a VIN decoder script and it pulls the default features and they can edit it if needed, and it edits in the DOM. It works perfectly but when I switch tabs to "Interior" and then go back to "Exterior" then the exterior content goes back to the original list and none of the updates were saved.
And this is probably because the main page is at add-vehicle.php and on that page this is how I get the content:
<div id="tabContent">
<div id="contentHolder">
<!-- The AJAX fetched content goes here -->
</div>
</div>
and the content is on features.php
var Tabs = {
'Mechanical' : 'features.php?feature=MECHANICAL&vin='+vin+'',
'Exterior' : 'features.php?feature=EXTERIOR&vin='+vin+'',
'Interior' : 'features.php?feature=INTERIOR&vin='+vin+'',
'Safety' : 'features.php?feature=SAFETY&vin='+vin+'',
}
Does anyone have any suggestions on how I can do this? What I want to happen is all of the inline edits will be saved, and I can switch through the differnet tabs and make those changes, and everything will be saved.
Not sure how well I explained this, please let me know if you need to see more code.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这比您可能预期的要复杂一些,您要在保存任何数据之前从 DOM 中删除表单。
当为每个选项卡重新加载代码时,您将重新开始处理表单。
您可以通过几种方法解决此问题:
This is a bit more complicated than you probably expect, you are removing the forms from the DOM before any data is saved.
When the code is loaded back in for each tab, you are starting over with the forms.
You can fix this a few ways: