简体   繁体   English

如何在引导程序中包含外部javascript文件

[英]how do I include an external javascript file with bootstrap

I'm trying to figure out how to include an external javascript file while I am using the bootstrap framework. 我正在尝试找出使用引导框架时如何包含外部javascript文件。 I figure it should be very simple to do but it seems to be giving me fits. 我认为这应该很简单,但是似乎很合适。

I have scripts/dsc.js that I am trying to load into a <div id="loadedContent"></div> 我有要加载到<div id="loadedContent"></div> scripts/dsc.js

The line of code in the JSP file is: JSP文件中的代码行是:

<li><a href="#" onclick="loadLocation('content/current.jsp');return false;">View Job (All Runs)</a></li>

in the external javascript file I have this as my simple javascript: 在外部javascript文件中,我将其作为简单的javascript:

$(function() {
    alert("Hi");

    loadlLocation = function(location) {
        $("#includedContent").load(location);
    };
});

I put this in the head declaration: 我把它放在头声明中:

<script src="scripts/dsc.js" type="text/javascript"></script>

I know that the src path is correct because the other includes for the bootstrap scripts work just fine. 我知道src路径是正确的,因为其他包含引导脚本的文件也可以正常工作。 The alert located in the dsc.js is not showing up with is pointing me to it not being included. dsc.js的警报未显示,提示我未将其包含在内。 Now, Bootstrap by default was loaded at the bottom (so I left it there), but I included my javascript file in the head declaration. 现在,默认情况下,Bootstrap加载在底部(因此我将其保留在底部),但是我的javascript文件包含在head声明中。 Is there something special that I have to do to include javascript files when using Bootstrap? 使用Bootstrap时,我必须要做些特别的事情来包含javascript文件吗?

That cant work! 那行不通! You have no access outside the jQuery Wrapper! 您无权访问jQuery包装器!

 var loadlLocation = function(location) {
      $(function() {
           $("#includedContent").load(location);
      });
 };

It actually ended up being an ordering problem. 它实际上最终成为订购问题。 Was already solved here by KirKill. 已经由KirKill解决。

How do i add jquery ui date picker, while already working with bootstrap library? 在已经使用Bootstrap库的情况下,如何添加jQuery ui日期选择器?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM