简体   繁体   中英

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. 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>

The line of code in the JSP file is:

<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:

$(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. The alert located in the dsc.js is not showing up with is pointing me to it not being included. Now, Bootstrap by default was loaded at the bottom (so I left it there), but I included my javascript file in the head declaration. Is there something special that I have to do to include javascript files when using Bootstrap?

That cant work! You have no access outside the jQuery Wrapper!

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

It actually ended up being an ordering problem. Was already solved here by KirKill.

How do i add jquery ui date picker, while already working with bootstrap library?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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