Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to use jQuery Datepicker in my website. However when I use the same I get the following error. Uncaught TypeError: Object # has no method 'datepicker' I've googled on this for quite sometime. All of these say that the problem could be due to loading jquery twice. I have checked and this isn't the case. I load the jQuery scripts in the following way.

<script type="text/javascript" src="http://xxxx/wp-includes/js/jquery/jquery.js"></script>
<script type="text/javascript" src="http://xxxx/wp-includes/js/jquery/ui/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="http://xxxx/wp-includes/js/jquery/ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://xxxx/wp-includes/js/jquery/ui/jquery.ui.datepicker.min.js"></script>
...
...
<input type="text" id="arrival-date-10">
<input type="text" id="departure-dat-14">
....
<script type="text/javascript">
jQuery(document).ready(function(){
    $("#arrival-date-10").datepicker();
    $("#departure-date-14").datepicker();
});
</script>

I get the error in line $("#arrival-date-10").datepicker();

Please can someone help me?

Partha

share|improve this question

closed as off topic by EAMann Jul 10 '12 at 15:13

Questions on WordPress Development Stack Exchange are expected to relate to WordPress within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

4  
What happens if you use jQuery(document).ready(function($){ instead? –  m0r7if3r Feb 4 '12 at 20:05
    
JS questions are not on-topic for this site. That said, you've already received plenty of useful answers below (and one spot-on in the comment above this one). –  EAMann Jul 10 '12 at 15:14

2 Answers 2

This line shouldn't be in there:

<script type="text/javascript" src="http://xxxx/wp-includes/js/jquery/ui/jquery-ui.min.js"></script>

In a standard WordPress install, no such file exists. This makes me wonder how you are adding the scripts to the theme in the first place. Are you using wp_enqueue_styles? If not, there is a VERY good chance that you are indeed adding two versions of jQuery.

share|improve this answer

You may be having a jQuery conflict. Give it a try in noconflict mode like so:

<script type="text/javascript">
(function($) {
$(document).ready(function(){
    $("#arrival-date-10").datepicker();
    $("#departure-date-14").datepicker();
});
})(jQuery);
</script>

I wonder if this wouldn't be better asked on Stack Overflow instead, it's not really a WordPress question (unless you're asking how to properly enqueue scripts).

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.