I am trying to use a library installed through npm: https://github.com/xdan/datetimepicker
I add it to the file in resources app.js next to jquery:
require('bootstrap');
window.$ = require('jquery');
window.jQuery = require('jquery');
window.datetimepicker = require("jquery-datetimepicker");
I have also tried to add it like this:
window.$.datetimepicker = require("jquery-datetimepicker");
And in page I use this code:
$(document).ready(function(){
$('.date').datetimepicker({step:30});
})
But always get the same error: $(...).datetimepicker is not a function
If I add the libraries directly, it works.
<link href="/js/jquery.datetimepicker.min.css" rel="stylesheet">
<script src="/js/jquery.datetimepicker.full.min.js"></script>
CodePudding user response:
try to rebuild your app
npm run dev
CodePudding user response:
Try the following...
window._ = require('lodash');
window.$ = window.jQuery = require('jquery');
require("jquery-datetimepicker");
require('bootstrap');
$(document).ready(function(){
$('.date').datetimepicker({step:30});
})
And make sure to add {{ mix('css/app.css') }}
at the top and {{ mix('js/app.js') }}
at the bottom.