samedi 1 septembre 2018

How to use `bootstrap-datetimepicker` in Laravel project?

I have a project based on Laravel 5.6. I am trying to use Laravel Mix to compile all my js/css resources.

I want to use a js datetime-picker that allows me to create a datetime-picker picker and a range picker on my page. Since I am using css-bootstrap for styling, I want to use bootstrap-datetimepicker in my project. I am having hard time trying to install this project.

Here is what I have code. Inside of my webpack.mix.js file, I have the following

const { mix } = require('laravel-mix');

mix.js('resources/assets/js/app.js', 'public/js')
    .scripts([
            'bower_components/eonasdan-bootstrap-datetimepicker/build/js/tempusdominus-core.min.js'
        ], 'public/js/app_addons.js')
   .sass('resources/assets/sass/app.scss', 'public/css');

and in my resources/assets/js/app.js I added the following code

window.datetimepicker = require('../../../bower_components/eonasdan-bootstrap-datetimepicker/build/js/tempusdominus-core.min.js');

But in the browser's console, I am getting the following error

TypeError: $(...).datetimepicker is not a function



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire