[英]Reloading of the js scripts via jquery load /ajax
Hi I Am working on a project.The design of the project is like this 嗨,我在一个项目上。项目的设计是这样的
<html>
<head>
some intail scripts that are needed like bootstrap and jquery and page specific scripts goes here that is required for the first launch
</head>
<body>
<div id=menu>
<!--we put bootstrap menu here-->
</div>
<div id=container>
<!--we load different html pages here using ajax call inside the div when user clicks on the menu we call page html using ajax and append it here -->
</div>
<div id=footer>
<!--Footer contents come here-->
</div>
</body>
The problem ,that i am facing is , suppose i designed a page that need a bootstrap and jquery 我面临的问题是,假设我设计了一个需要引导程序和jquery的页面
So i placed the file in the page but these files are also present in the homepage where i am going to load the contents using the ajax.So we end-up having two times jquery and bootstrap on the page , this causes few problems like my menu stop working 所以我将文件放在页面中,但这些文件也存在于我要使用ajax加载内容的主页中,因此我们最终在页面上有两次jquery和bootstrap,这会引起一些问题,例如菜单停止工作
and if i remove the bootstrap from the page that i am going to load few functionality of the page stop working like bootstrap modals doesn't show up and say undefined functions but bootstrap is present in the main page where i am loading this page html using ajax. 如果我从要加载的页面上删除引导程序,则该页面的一些功能会停止工作,如引导程序模态不会显示并说未定义函数,但是引导程序存在于我要加载此页面的html主页中阿贾克斯。
one thing i am sure it a project design flaw but this project is on a level where we cant change the structure . 我确信这是项目设计的缺陷,但是这个项目处于我们无法改变结构的水平。
So i need help that how should i stop reloading of the scripts and maintain every thing working. 因此,我需要帮助,该如何停止重新加载脚本并保持所有工作正常进行。
One more thing the main page is index.html and back-end is in spring framework 主页的另一件事是index.html,后端在spring框架中
I can see two posible solutions: 我可以看到两个可能的解决方案:
<div id=container>
, put them into an iframe
. <div id=container>
,请将它们放入iframe
。 Are you sure that using simple JQuery $load() over that div is not getting the includes of the main page? 您确定在该div上使用简单的JQuery $ load()不会获得主页的包含吗?
I always add HTML code to my DOM using load and I dont need to include the js or css for every injected page. 我总是使用负载将HTML代码添加到DOM中,并且不需要为每个插入的页面都包含js或CSS。
$('#container').load("url_controller_where_you_will_render_the_html_to_inject");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.