Hi everyone,
On a Laravel 5.4 project, I want to use the Flatpickr with Wepback, thus I pulled it in via yarn add -dev flatpickr and put the following lines in my bootstrap.js:
const Flatpickr = require('flatpickr');
My app.js file looks like this:
require('./bootstrap');
$(document).ready(function() {
$('.js-datepicker').flatpickr({
altInputClass: '',
altInput: true,
altFormat: 'd.m.Y',
dateFormat: 'Y-m-d',
});
});
Unfortunately, I get this error: Uncaught TypeError: $(...).flatpickr is not a function.
So I tried to use another approach:
$(document).ready(function() {
const Flatpickr = require('flatpickr');
new Flatpickr(document.querySelectorAll('.js-datepicker'), {
altInputClass: '',
altInput: true,
altFormat: 'd.m.Y',
dateFormat: 'Y-m-d',
});
});
But this doesn't work either: Uncaught ReferenceError: Flatpickr is not defined and Uncaught TypeError: Cannot read property 'add' of undefined.
In another Laravel 5.3 project, where I use gulp instead of webpack, it works.
Can you help me to spot the error?
Thanks in advance and have a nice day :)