Datepicker Multiple Dates not working in Google Ap

2019-09-03 23:22发布

问题:

I am trying to create a datepicker that allows users to select multiple dates. These are the javascript and stylesheet references I am using:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="http://multidatespickr.sourceforge.net/jquery-ui.multidatespicker.js"></script>

<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css" />

This is the function I am calling once the document is ready:

try{
  $("#recievedInHouseDate").multiDatesPicker();
}catch(e){
  alert(e)
};

And the alert I get is: TypeError: $(...).multiDatesPicker is not a function

Any idea why this wouldn't work. I can get the regular date picker working fine if I only want to select a single date.

回答1:

Why do you import jquery-ui twice?

here:

script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js">/script

and here:

script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js">/script

I think you should remove one of them. At least in my case that caused a similar to yours problem with Datepicker.



回答2:

Try this line to avoid any conflict while loading jQuery libraries

jQuery.noConflict();