lundi 20 juillet 2020

Laravel 5.8 how to include node_modules

I need to include tempusdominus datetimepicker to my Laravel 5.8 project but I am no able to load the scipts and styles correctly.

According documentation I tried to add this lines to my bootstrap.js.

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

    mix.copy('ode_modules/tempusdominus-bootstrap-4/build/css/tempusdominus-bootstrap-4.min.css', 'public/css/tempusdominus.css');

    require('bootstrap');
    require('moment');
    require('tempusdominus-bootstrap-4');

    require('./main.js');
} catch (e) {}

Watcher sayis everything was compiled successfully but console throws me an error $(...).datetimepicker is not a function

The script with $().datetimepicker is includec via section at the very end of the file this way.

@section('scripts')
    <script type="text/javascript">
        $(function () {
            $('#datetimepicker1').datetimepicker({
                locale: 'sk'
            });
            $('#datetimepicker2').datetimepicker({
                locale: 'sk'
            });
        });
    </script>
@endsection

What am I doing wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire