8

My test div is below. If I put all of this into its own page, everything works perfectly. If it put it onto my final page, I get an error saying that datepicker() is undefined.

How do I figure out what is causing jQuery UI to break?

<div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>

<link type="text/css" href="../css/ui-lightness/jquery-ui-1.8.18.custom.css" rel="stylesheet" />

<script type='text/javascript'>
$(document).ready(function() {

    //for calendar
    $("#date_to").datepicker();
    $("#date_from").datepicker();
    //end for calendar
})
</script>

<input id='date_to'>
<input id='date_from'>
</div>
7
  • 2
    Seems to work here: jsfiddle.net/Vvmxx. I'd assume there may be some other code in your page which is causing an error and the datepicker error is a by-product. Commented Apr 3, 2012 at 19:26
  • Can you provide either source or link to your final page? Also, what does the console say? Just jQuery.ui undefined? Commented Apr 3, 2012 at 19:26
  • I concur with @RoryMcCrossan that the datepicker is a by-product. Commented Apr 3, 2012 at 19:27
  • This is probably not related to your issue, but: it's a good habit to load your stylesheets before your scripts, and to put both in your document's <head>. Commented Apr 3, 2012 at 19:31
  • Unfortunately, I cannot link to the final produce (behind a login). My question is: what tools can I use/methods should I try to isolate the bug and figure out what's wrong. The console just says that datepicker is undefined. Commented Apr 3, 2012 at 19:32

2 Answers 2

20

Make sure you didn't accidentally reference jQuery twice. I had an older version of jQuery loading after jQuery UI, which was jacking things up. =/

Sign up to request clarification or add additional context in comments.

3 Comments

Just had a similar problem: loading jQuery UI twice breaks droppable for the first item using it (at least that's how it appeared).
I'd like to add that I had another library load the older version of jQuery on top of my own reference. That's why it wasn't so easily discovered.
If you include DataTables using the Download Builder, KNOW WHETHER OR NOT you are including the jQuery option with DataTables. If you are, do not include jQuery independently. If you are not, you MUST include jQuery independently. This burned me! Thanks for the tip.
0

Be sure that when you generate your jQuery UI package here: http://jqueryui.com/download, you select the element Datepicker. I saw that you are using the version hosted by Google, it works fine here, they provide it: jQuery UI Datepicker 1.8.18 (look at the source code). To figure out what is causing jQueryUI to break, besides debugging:

  • Test at jsfiddle.net;
  • Test in other local enviroment (other browsers as well);

Hope it helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.