samedi 25 février 2017

How to get jQuery to work with Laravel?

I'm trying to get jQuery to work with Laravel 5.4. I installed jQuery with npm. I have two files in the same folder: app.js and bootstrap.js. From app.js I import the file bootstrap.js with:

`require('./bootstrap');

In bootstrap.js I import jQuery with:

window.$ = window.jQuery = require('jquery');

Still in my blade view when I try:

<script>
    $(document).ready(function () {
        console.log('jQuery is working!');
    });
</script>

I get a referene error telling me that "$ is not defined".

Any idea what I am doing wrong? Thank you in advance.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2laWmlF
via IFTTT

Aucun commentaire:

Enregistrer un commentaire