【发布时间】:2014-06-11 09:53:57
【问题描述】:
你好我正在做一个项目。项目的设计是这样的
<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>
我面临的问题是,假设我设计了一个需要引导程序和 jquery 的页面
所以我将文件放在页面中,但这些文件也存在于主页中,我将使用 ajax 加载内容。所以我们最终在页面上有两次 jquery 和引导程序,这导致很少问题 喜欢我的菜单停止工作
如果我从页面中删除引导程序,我将加载页面的一些功能停止工作 bootstrap modals 没有显示并说未定义的功能,但 bootstrap 出现在我正在使用 ajax 加载此页面 html 的主页中。
我确信这是一个项目设计缺陷,但这个项目处于我们无法改变结构的水平。
所以我需要帮助,我应该如何停止重新加载脚本并保持一切正常。
还有一点,主页面是index.html,后端是spring框架
【问题讨论】:
-
如果我正确理解了您的问题,您应该在需要的每个 HTML 页面中加载 JS 和 CSS 文件。
-
@pilot 是的,但是当我在每个上都包含 js 和 css 时,问题是 js 可能已经像 jquery 一样存在于 index.html 中,所以当我使用 ajax 调用页面时会有 2 jQuery 加载
标签: java javascript jquery html spring