I have been trying to use bootstrap datetimepicker and have all the components on my scripts like Moment JS, bootstrap-date-time js, and bootstrap js but I am getting g.size() is not a function error. I am trying to run the following function
$(function(){
$('#datetimepicker').datetimepicker();
});
I had the same error as you, and I could not find a solution for it anywhere. In fact the only reference to the g.size() is not a function
error was this question, at the time with only a single down vote.
I found this one: https://github.com/xdan/datetimepicker, it was quite easy to get working:
download the zip from github
Include the files :
<link href="./js/datetimepicker-master/build/jquery.datetimepicker.min.css" rel="stylesheet"> <script src="./js/datetimepicker-master/build/jquery.datetimepicker.full.min.js"></script>
This HTML
<input id="datetimepicker" type="text" />
And this JS
$.datetimepicker.setLocale('en');
$('#datetimepicker').datetimepicker();
I got this up and working in a tiny fraction of the amount of time I'd wasted trying to get the bootstrap datetimepicker to stop giving me the g.size()
error.
Of course there are many other datetime pickers available:
.size()
was removed in version 3 of jQuery, use .length
instead.
In your example, replace g.size()
for g.length
.
The g.size error is known by the developers and exists with newer versions of jquery.
If you wish to use that datetimepicker then go back to jquery 2.1.4 or earlier.
The bug is listed here :
https://github.com/Eonasdan/bootstrap-datetimepicker/issues/1714
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With