5

I'm trying to implement Trent's timepicker, but I'm not being able to do it. I'm testing it in Chrome, Firefox, and IE9.

I already imported Jquery and Jquery UI. The only common error I could find was that Jquery UI wasn't the full version(without slides), but that's not my case. Anyway, the errors are the following

Cannot set property 'formatTime' of undefined (line ...)
$.datepicker.formatTime = function(format, time, options) { (this is the line)

Cannot call method '_newInst' of undefined
$t.datepicker($.timepicker._newInst($t, o)._defaults);

I would thank any help, I'm really new at jQuery and I don't really get it.

halfer
  • 19,824
  • 17
  • 99
  • 186
iBadell
  • 81
  • 1
  • 5
  • Make sure that jQuery is being loaded and isn't raising any errors itself. Then add in the timepicker library without instantiating it (comment this stuff out as necessary) and ensure that doesn't raise any errors. That might help you narrow down the cause. Finally double-check how you're initialising it - it might be your call is wrong. Would you add your instantiation code and the relevant html snippet? – halfer Feb 23 '12 at 21:20
  • (Btw, when asking questions about specific plugins that may not be widely known, it is helpful to hyperlink to the home page for that project, to save others having to google it.) – halfer Feb 23 '12 at 21:21
  • Sorry, i forgot to link. Jquery ui works, i'm using the datepicker widget, and shows me no problems. Here is the html `` `` And the js where i call datepicker `$('#hora_ini').timepicker({});` – iBadell Feb 24 '12 at 19:15
  • No probs about forgetting - but do remember that you can edit a post to add such things in :) – halfer Feb 24 '12 at 23:47
  • Just a guess - maybe take out the empty hash from your timepicker() call? – halfer Feb 24 '12 at 23:48

5 Answers5

1

Download full version of jquery-ui here, but check all boxes including "Datepicker". Then replace your jquery-ui js file and run your project. Worked for me.

sloth
  • 99,095
  • 21
  • 171
  • 219
Cris
  • 11
  • 1
1

I had this exact same problem earlier today. I solved it by making sure I had the latest versions of jQuery and jQuery UI (at first I only updated jQuery and the problem persisted). I would also make sure you have the latest version from Trent Richardson.

Mike L
  • 11
  • 1
  • Didn't worked. I have the latest version of all, i even tried with Trent's dev latest release, but i can't, it's really annoying me.. Thanks anyway – iBadell Feb 23 '12 at 18:22
1

Use it with an object as input, meaning the extra curly braces:

<input type="text" name="pickuptime" id="pickuptime" value=""  /> 
$('#pickuptime').datetimepicker( { } );

instead of this:

<input type="text" name="pickuptime" id="pickuptime" value=""  /> 
$('#pickuptime').datetimepicker( );
Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
0

Looks like you are having an issue referring to jquery UI with datepicker

from date time picker web site

enter image description here

try this reference before your date time picker and after jquery reference

<script type="text/javascript" 
src="http://code.jquery.com/ui/1.10.3/jquery-ui.js">
Mina Gabriel
  • 23,150
  • 26
  • 96
  • 124
0

I had exactly the same problem last night. The cause of the problem turned out that timepicker javascript file was loaded after the jQuery UI javascript. Since timepicker wants to use $.datepicker that should have been initialized in jQuery UI, it failed miserably.

In my personal situation, I am using it on Ruby on Rails environment, and I let the order of the javascript loading handled by asset pipeline. It is a nice environment that handles javascript loading with minifying automatically. But I gave that up and went back to linking js files from html manually, and voila! It worked.

barley
  • 4,403
  • 25
  • 28