Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is jqueryUI datepicker throwing an error?

I am trying out jqueryUI, but firebug catches the following error on this script:

$(function(){$("#date").datepicker()});

The firebug error reads:

$("#date").datepicker is not a function

On my html, the "date" id looks like this:

<input type="text" name="date" id="date" >

NB: I have used the correct JqueryUI css/js scripts on the section

Nothing is executing...

like image 944
Gath Avatar asked May 21 '26 10:05

Gath


2 Answers

jQuery documentation says you can call the datepicker by this command:

$("#datepicker").datepicker();

If you click the 'view source' button on the documentation page you can see that they've wrapped it into the ready function:

$(document).ready(function(){
    $("#datepicker").datepicker();
  });

EDIT: It should work with INPUT (thanks for pointing this out Steerpike). This is the test I've written and it works, try it yourself:

<html>
<head>
  <link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
  <script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
  <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
  <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.datepicker.js"></script>
  <script type="text/javascript">
  $(document).ready(function(){
    $("#datepicker").datepicker();
  });
  </script>
</head>
<body>
  <input type="text" id="datepicker" value="this is a test">   
</body>
</html>
like image 99
RuudKok Avatar answered May 23 '26 22:05

RuudKok


You're almost certainly not loading the datepicker plugin properly. Please supply us the code you're using to include the javascript files.

If you keep having problems, load the jquery and the UI from the google api.

<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
    google.load("jquery", "1.3.2");
    google.load("jqueryui", "1.7.0");
</script>
like image 22
Steerpike Avatar answered May 23 '26 23:05

Steerpike



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!