lundi 17 décembre 2018

Laravel webpack including custom javascript

When I do the below, I get 'Uncaught Reference Error Slideout is not defined' in my console.

In resources/js/app.js:

require('./slideout');

Code in blade template right before </body>:

<script src=""></script>
<script type="text/javascript">
$(function () {

    var slideout = new Slideout({
        'panel': document.getElementById('panel'),
        'menu': document.getElementById('menu'),
        'padding': 256,
        'tolerance': 70
    });

});
</script>

If I check the generated app.js file I can see that all the Slideout code is there. So it's included properly.

But if I do this (add slideout.min.js through CDN), it works:

<script src=""></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slideout/1.0.1/slideout.min.js"></script>
<script type="text/javascript">
$(function () {

    var slideout = new Slideout({
        'panel': document.getElementById('panel'),
        'menu': document.getElementById('menu'),
        'padding': 256,
        'tolerance': 70
    });

});
</script>

Why doesn't it work when the Slideout code is in the app.js file?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire