views:

231

answers:

3

I am having trouble displaying the jQuery datepicker as shown here: http://jqueryui.com/demos/datepicker/

I believe I downloaded all of the proper files, but to be certain, I started from scratch and ripped the demo site. Not all of it, but what I believed to be the important parts. The result is no datepicker to be shown and no javascript errors. Here is my full code sample:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
 <link rel="stylesheet" href="http://static.jquery.com/ui/css/base2.css" type="text/css" media="all" />
 <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css" type="text/css" media="all" />
 <link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" />


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"&gt;&lt;/script&gt;
<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"&gt;&lt;/script&gt;

<script type="text/javascript" charset="utf-8">
 jQuery(function(){
  jQuery("#datepicker").datepicker();
 });
</script>
</head>
<body>
<input type="text" id="datepicker" class="hasDatepicker" />
</body>
</html>

Any help would be very much appreciated. Thanks!

+8  A: 

Please take out the class="hasDatepicker" and it should work. Don't know how but it works.

HTH

Raja
Yes, that class name is used by jquery-ui to indicate that a datepicker has already been added.
interjay
The hasDatepicker class is automatically added by jQuery UI when you call datepicker. Putting it in yourself messes things up.
Adam
Guess I shouldn't have ripped the code. Thank you!
Bill Brasky
+1  A: 

If you look carefully at the source code of jQuery UI lib you can see that it uses hasDatepicker class inside for datepicker. So, use any other class (even hasdatepicker works) but not hasDatepicker:

<input type="text" id="datepicker" class="anyOtherClassName"/>

or:

<input type="text" id="datepicker" class="hasdatepicker"/>
Bar
A: 

Remove class="hasDatepicker"

kekekela