datepicker should work normally as in version 1.7.0
In version 1.7.1 browser throws error
Uncaught TypeError: $(...).datepicker is not a function
1.7.1
Problem happens when code is bundled with laravel-mix (webpack).
app.js
...
require("bootstrap-datepicker")
...
used in html:
<script type="text/javascript">
$(document).ready(function(){
$('.input-daterange').datepicker({
format: 'yyyy-mm-dd',
weekStart: 1,
autoclose: true
});
});
</script>
Downgrading back to 1.7.0 helps.
@andreypopp @Mithgol is it possible this is related to the dependency on jquery in dependencies/peer-dependencies?
@ipa1981 did it work on 1.6.4?
@acrobat Yes, 1.6.4 works as well.. Problem is relevant to 1.7.1 only.
@acrobat If it were related to the dependencies / peerDependencies, than 1.7.0 would聽be broken and聽1.7.1 would work聽again because b56efd6153a9fd3e46df0c911e204bd8af14dddc reverts 84e96f469dd53484d04163a20722c85b30bf4324 right? Therefore it's probably something聽else.
Is there a fix for this yet? If not, how do I get v1.7.0 since apparently that works.
Never mind, my fault, permissions were wrong on the datepicker.js file.
I can confirm that it's not working because jquery is defined in dependencies but it should be in peerDependencies and because of that, yarn is fetching a different version of jquery to node_modules/bootstrap-datepicker/node_modules/jquery.
Version v1.7.0 (with jquery in peerDependencies) works and my recommended workaround is to keep with that version :+1:
Please check #2163 for the reasons of reverting. I don't know what is best or what we should do, so please help use fixing this issue without breaking the original issue of #2163. Thanks!
Just ran into this exact same issue which cropped up when upgrading node >= 8 due to the differences in the way npm >= 5 manages packages. We use webpack to manage our builds and when running npm >=5 we would wind up with two different versions of jquery being loaded in our builds since we explicitly list jquery as a dependency in our project as does bootstrap-datepicker. When webpack resolves the dependencies, it sees that bootstrap-date picker has its own local dependency and loads that separately from the jquery that was previously imported. I think the real fix is to make jquery a peerDependency and anyone relying on this downstream should need to include jquery explicitly themselves as a dependency. Of course, this should be released with a major sem-version bump to prevent issues like #2206 from being filed again.
Resolved?
Hey, I use Webpack and it seems I have the exact same issue with version > 1.7.0 :/
Do you know what to do to fix it so I could open a PR eventually ? Thanks
Most helpful comment
Just ran into this exact same issue which cropped up when upgrading node >= 8 due to the differences in the way npm >= 5 manages packages. We use webpack to manage our builds and when running npm >=5 we would wind up with two different versions of jquery being loaded in our builds since we explicitly list jquery as a dependency in our project as does bootstrap-datepicker. When webpack resolves the dependencies, it sees that bootstrap-date picker has its own local dependency and loads that separately from the jquery that was previously imported. I think the real fix is to make
jqueryapeerDependencyand anyone relying on this downstream should need to includejqueryexplicitly themselves as a dependency. Of course, this should be released with a major sem-version bump to prevent issues like #2206 from being filed again.