0

I get 'undefined is not a function' for my script when using both the jquery-ui.js and jquery.js scripts. I need the 'ui' for my datepicker, but the rest of items (not shown) on the page need jquery.js. Any ideas?

<!DOCTYPE html />
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<META http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" TYPE="text/css" HREF="/img/style/screen.css">
<link rel="stylesheet" TYPE="text/css" HREF="/Test/pbforms.css" />
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">         
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<script type="text/javascript" src="/img/adn/scripts/jquery.js"></script>
<script>
$(function() {
    $('#_1_1_2_1').datepicker({
        dateFormat: 'yy-dd-mm',
        onSelect: function(datetext){
            var d = new Date(); // for now
            datetext=datetext+" "+d.getHours()+": "+d.getMinutes()+": "+d.getSeconds();
            $('#_1_1_2_1').val(datetext);
        },
    });
});
</script>
</head>
<body>
<p>Date: <input type="text" id="_1_1_2_1"></p>
</body>
</html>
3
  • Please add some clean code... with proper formatting, its very difficult to even edit this post for formatting... Commented Jul 10, 2014 at 14:29
  • Why you are using two versions of jquery - jquery-1.10.2.js and jquery.js? May be removing last line - <script type="text/javascript" src="/img/adn/scripts/jquery.js"></script> your code should work Commented Jul 10, 2014 at 14:29
  • _1_1_2_1 is not a very good id for a textbox. Commented Jul 10, 2014 at 14:32

2 Answers 2

1

It seems you are loading jquery two times:

<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="/img/adn/scripts/jquery.js"></script>

I removed the second line and the datepicker works.

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

Comments

1

If I add just jQuery and jQuery ui script it works fine. Not sure what your last script /img/adn/scripts/jquery.js is suppose to be. If it is another version of jQuery then it won't work because jQuery needs to be loaded before jQuery UI and you only need to include it once.

Note: You also want to make sure your jQuery Version and jQuery UI version are compatiable with each other. A fail safe is to just get the latest of both libraries.

HTML:

<p>Date: <input type="text" id="_1_1_2_1"></p>

JS:

$(function() {
    $('#_1_1_2_1').datepicker({
        dateFormat: 'yy-dd-mm',
        onSelect: function(datetext){
            var d = new Date(); // for now
            datetext=datetext+" "+d.getHours()+": "+d.getMinutes()+": "+d.getSeconds();
            $('#_1_1_2_1').val(datetext);
        },
    });
});

Demo:

http://jsfiddle.net/57GLh/1/

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.