Melodia's avatar

Datetimepicker not working

Am trying to use datetimepicker and the reference is here: https://www.malot.fr/bootstrap-datetimepicker/

So, I downloaded the files and compiled them in my webpack which looks like this

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');

mix.styles([
    'resources/assets/css/libs/style.css',
    'resources/assets/css/libs/bootstrap.min.css',
    'resources/assets/css/libs/bootstrap-datetimepicker.min.css',
    'resources/assets/css/libs/pgwslider.min.css',
    'resources/assets/css/libs/slider.css',
    'resources/assets/css/libs/fonts.css',

], 'public/css/libs.css');


mix.scripts([
    'resources/assets/js/libs/jquery-3.3.1.min.js',
    'resources/assets/js/libs/bootstrap.js',
    'resources/assets/js/libs/bootstrap-datetimepicker.min.js',
    'resources/assets/js/libs/pgwslider.min.js',
    'resources/assets/js/libs/scripts.js',
    'resources/assets/js/libs/slider.js'

], 'public/js/libs.js');

Here is my header:

<script src="{{ asset('js/libs.js') }}" defer></script>

<script type="text/javascript">
    $(function(){
        $('#datetimepicker1').datetimepicker();
    })
</script>

In my view I have the input to save the date

<input id="datetimepicker" placeholder="Date and Time" type="text" name="date_and_time1" class="form-control">

When I click on the input field, nothing happens. Anything I could have possibly done wrong?

0 likes
5 replies
jlrdw's avatar

change id datetimepicker to datetimepicker1

Melodia's avatar

@jlrdw I had changed to that and it does not make a difference. I had even changed to a different id name

jlrdw's avatar

Clear browser cache and delete the temp views.

Melodia's avatar

It seems like it is something to do with my script that is in the header.

I put this line $('#datetimepicker1').datetimepicker(); inside my js file and it works!

jlrdw's avatar

That' what I meant, the id wasn't matching at first.

You had id="datetimepicker" instead of id="datetimepicker1"

Please or to participate in this conversation.