Why is jqueryUI datepicker throwing an error?

18,879

Solution 1

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>

Solution 2

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>

Solution 3

for me it was just case of making sure the jquery ui was the last one in the list of all the js includes.

Solution 4

It's an old post but I got here when looking for a solution so people still read it ;) I have or rather had the same problem. In my case it turned out that I was attaching js in html in wrong way (notice in what way I was ending script tag)

WRONG: <script type="text/javascript" src="/fbo/js/jquery-ui-1.8.14.custom.min.js"/>

GOOD: <script type="text/javascript" src="/fbo/js/jquery-ui-1.8.14.custom.min.js"></script>

When I was doing it in the wrong way I had the same error.

Solution 5

 $(document).ready(function(){
  // Your code here
 });

make sure your function is inside the .ready main function.

Share:
18,879
Gath
Author by

Gath

Updated on June 04, 2022

Comments

  • Gath
    Gath almost 2 years

    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...