lundi 17 décembre 2018

Laravel order of included libraries and custom code referencing these

In resources/js/app.js there is this line: require('./bootstrap');.

If I add a line below that, require('./custom-stuff');, put custom-stuff.js in resources/js I can see that it's included in app.js. So far so good.

I'm puzzled however by the order that the files are included. If in custom-stuff.js I add:

$(function () {
    $('[data-toggle="tooltip"]').tooltip()
});

it doesn't activate the tooltip, while I see the code being included in app.js.

If I add the tooltip activation code above in my Blade template right before the closing </body> tag (and before the inclusion of app.js), it does work.

Why is this? I would like to keep everything in app.js including custom code that refers to other libraries that are included.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire