0
votes

I am not able to fix a datepicker in my site.Error i am getting is Uncaught TypeError: Object [object Object] has no method 'datepicker'.my code is

<head>
<script src="{{ STATIC_URL }}scripts/modernizr-2.0.6.min.js"></script>
<script src="{{ STATIC_URL }}scripts/jquery-1.9.1.min.js"></script>
<script src="{{ STATIC_URL }}scripts/jquery-ui.js"></script>
<script src="{{ STATIC_URL }}scripts/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(function () {
    $( "#datepicker" ).datepicker({
      showOn: "button",
      buttonImage: "{{ STATIC_URL }}images/icon.png",
      buttonImageOnly: true
    });
  }); 
</script>
</head>

It is dispatching the error"Uncaught TypeError: Object [object Object] has no method 'datepicker'".Can i get a solution for this.

Thanks

2
Why are you importing jQuery twice? Are you sure you included the datepicker widget in your build of jQueryUI? - Pointy
Maybe jquery ui extends jquery and then it gets overwritten by jquery because you add that again after jquery ui. - HMR
@Pointy,u r correct,it is resolved.Thanks - user2086641

2 Answers

1
votes

Do not import the jQuery library twice.

This is the main cause for all the problem like these

0
votes

try this

<head>
<script src="{{ STATIC_URL }}scripts/modernizr-2.0.6.min.js"></script>
<script src="{{ STATIC_URL }}scripts/jquery-1.9.1.min.js"></script>
<script src="{{ STATIC_URL }}scripts/jquery-ui.js"></script>
<script src="{{ STATIC_URL }}scripts/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(function () {
var jq = $.noConflict();
    $( "#datepicker" ).datepicker({
      showOn: "button",
      buttonImage: "{{ STATIC_URL }}images/icon.png",
      buttonImageOnly: true
    });
  }); 
</script>
</head>