Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve Cannot read property 'timepicker' of undefined error

I am trying to implement the Jquery datetime picker on web page but keep getting the following error:

Uncaught TypeError: Cannot read property 'timepicker' of undefined

I downloaded the timepicker add on from here:

http://trentrichardson.com/examples/timepicker/#basic_examples

http://trentrichardson.com/examples/timepicker/jquery-ui-timepicker-addon.js

Here is the section of the code generating the error:

$.ui.timepicker = $.ui.timepicker || {};
if ($.ui.timepicker.version) {
    return;
}

On my web page I have the following:

<script type="text/javascript" src="/Scripts/jquery-lib/jquery-2.0.3.js"></script>

<script type="text/javascript"  src="/Content/bootstrap/js/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript"  src="/Content/bootstrap/js/jquery.ui.datepicker.js"></script>
 <script type="text/javascript"  src="/Content/bootstrap/js/jquery-ui-sliderAccess.js"></script>

And script:

<script>
    $(function () {
        $("#datetimepicker").datepicker();
    });

like image 488
Milligran Avatar asked Sep 01 '13 15:09

Milligran


1 Answers

Uncaught TypeError: Cannot read property 'timepicker' of undefined means that

$.ui

is undefined. So, you probably have not included jQuery UI. Try to include it before any of your scripts (except jQuery itself).

like image 158
Vincent Vieira Avatar answered Oct 15 '22 11:10

Vincent Vieira