Drakota
Drakota

Reputation: 357

Can't include internal JS file in Laravel 5

I have a simple .blade.php view for a Laravel application, I'm trying to include a JS file, which is in /public/js directory in my project.

<!DOCTYPE HTML>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="{{ URL::asset('js/chartkick.js') }}"></script>
<html>
    <body>
        <div id="chart-1" style="height: 300px"></div>
        <script>
            new Chartkick.LineChart("chart-1", {"2013-02-10 00:00:00 -0800": 11, "2013-02-11 00:00:00 -0800": 6})
        </script>
    </body>
</html>

It looks like this, but when I try to display this I get

test:8 Uncaught ReferenceError: Chartkick is not defined
    at test:8

In Chrome developer console, the JS file doesn't seems to be properly included in my project. Why?

Thanks for helping.

EDIT :

Here's the file structure

public
├── css
│   └── app.css
├── favicon.ico
├── js
│   ├── app.js
│   └── chartkick.js
├── robots.txt
└── web.config

Upvotes: 1

Views: 1834

Answers (3)

Jesus Erwin Suarez
Jesus Erwin Suarez

Reputation: 1585

Also try this one {{ url('public/js/chartkick.js') }}

Upvotes: 0

Exprator
Exprator

Reputation: 27513

{{ asset('public/js/chartkick.js') }}

use this

Upvotes: 3

Ersin Feyzioglu
Ersin Feyzioglu

Reputation: 66

Can you change this

URL::asset('js/chartkick.js')

to

URL::asset('/js/chartkick.js')

Upvotes: 0

Related Questions