Nicky Thomas
Nicky Thomas

Reputation: 165

Uncaught TypeError: Object [object Object] has no method 'datetimepicker'

I've been reading through the answers on here but nothing seems to be working on their solutions, for some reason I am getting a console error "Uncaught TypeError: Object [object Object] has no method 'datetimepicker'" when I am using a button to load up the script using fancybox, but the crazy thing is. If I natively call the function using JavaScript through the calendar we are using directly it works fine, but we would like it to work on the button, which it previously did before the installation of new plugins.

$('#Time').datetimepicker({
datepicker:false,
format:'H:i',
step:30,
minTime: '07:00',
maxTime: '21:00'

});

Anyone have any ideas? The HTML is below

<tr>
<td>Time:</td>
<td>
<input type="text" id="Time" name="Time" value="<?php
if(isset($Time)) echo $Time; ?>" class="inputBoxSmall time" />
</td>
</tr>

Update: I've just noticed this -> Uncaught ReferenceError: jQuery is not defined jquery-ui.min.js:5

<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js">   </script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

Upvotes: 0

Views: 972

Answers (2)

Nouphal.M
Nouphal.M

Reputation: 6344

First of all Jquery is the base source file and jQuery UI uses the jQuery source file. So the order of the including script has to be reversed. And secondly i guess you are using jQuery DateTimePicker plugin. "A jQuery plugin is simply a new method that we use to extend jQuery's prototype object".The idea of a plugin is to do something with a collection of elements. Usually almost all plugins comes with a separate js file and if needed a stylesheet also. So in your case

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
<script src="path to your datepicker plugin here"></script>
<link rel="stylesheet" type="text/css" href="path to your plugin style sheet here"/>

You can see working examples here

Upvotes: 1

Scopey
Scopey

Reputation: 6319

You are including scripts in the wrong order.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js">   </script>

jQuery must come before jQuery UI.

Upvotes: 0

Related Questions