0

Below is what I have in my head section in my base html page. This script works- just like how I want it to. How do I add the script to static folder? Like I want to create a seperate js folder and make file for this script.

    <head>
    <link href="{{ STATIC_URL }}reservation/css/main_css.css" rel="stylesheet">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <script>
        $(document).ready(function(){
            $(".asu").click(function(){
            var foo = $(this).text()
            alert(foo);
           });
        });
   </script>
   </head>
trant trum
  • 219
  • 5
  • 14

1 Answers1

2

You can always do:

<head>
    <link href="{{ STATIC_URL }}reservation/css/main_css.css" rel="stylesheet">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <script src="{{ STATIC_URL }}reservation/js/main.js"></script>
</head>

Now, in the file main.js (Assuming you want the folder structure to be reservation/js under the {{STATIC_URL}})

$(document).ready(function(){
    $(".asu").click(function(){
        var foo = $(this).text()
        alert(foo);
   });
});

Just make sure jquery is loaded before your custom js file.

karthikr
  • 97,368
  • 26
  • 197
  • 188