1

EDIT: It started working after I deletd all the jQuery-related jS-files/packages in my Scripts folder, then simply added the online versions of the important files in the head section of the HTML, like so:

<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js' type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.12.0/jquery-ui.js" type="text/javascript"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" /> 

Of course I still don't understand exactly WHY it didn't work earlier. It's true that I noticed some different jQuery-versions (i.e., basically the same files but with different version numbers) in my Scripts folder, but even after I removed the doubles the datepicker still didn't work. It only started working after I deletd all the relevant files in my Scripts folder, then added the above links in my HTML. At least it's working now, and I don't have time to look further into this. But may have to come back to this later, as this is not really a nice solution.

I also found this question: jQuery UI " $("#datepicker").datepicker is not a function". But although I feel my issue may be similar to the one described there, I couldn't really apply the solutions/approaches presented there to my own case.

What follows is the original question:

I have this:

<script>
    $('#testTooltip').tooltip();
    $('#testDatepicker').datepicker();
</script>

<p id="testTooltip" title="These words will appear in the tooltip">
Hello, I'm testing the tooltip
</p>

<input id="testDatepicker" type="text" />

Surprisingly, the tooltip works fine, but the datepicker does nothing. In fact, for the datepicker I get the error message:

TypeError: $(...).datepicker is not a function

I'm working in the ASP.NET / MVC framework, which should mean that the required jQuery files are in the right place and are automatically included in my files without me having to add script tags for that purpose. But anyway, as far as I'm aware, the code for both the tooltip and the datepicker resides in jquery-ui.js (a file which I haven't changed or touched of course). So if the tooltip works, meaning that the call to function tooltip() works fine, how can it be that the function datepicker() isn't recognised as well?

Thanks.

Community
  • 1
  • 1
Holland
  • 395
  • 9
  • 22
  • Hello. Instead of this code `$('#testDatepicker').datepicker();` change it into `$('#testDatepicker').datepicker({chageMonth: true, changeYear: true});`.. Hope it works. – KiRa Jan 09 '17 at 03:14
  • Thanks, I tried it (with 'changeMonth' instead of 'chageMonth'), but it didn't work. – Holland Jan 09 '17 at 03:18
  • did you add your script?. – KiRa Jan 09 '17 at 03:19
  • If you tooltip is fine then try this one. `` – KiRa Jan 09 '17 at 03:21
  • Yes, that did it! Many thanks. If you change your last comment into an answer, I will accept it. – Holland Jan 09 '17 at 03:37
  • Well, I have to correct myself here. There was a datepicker, but it was not the jQuery datepicker. I'm testing in Chrome, which has it own datepicker, and making type='date' made the Chrome datepicker appear -- not the jQuery one. Which took me some time to realise. Sorry about the confusion. – Holland Jan 09 '17 at 03:43
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/132663/discussion-between-kira-and-holland). – KiRa Jan 09 '17 at 03:51

1 Answers1

0

You can use type = "date". Sample

<input id="testDatepicker" type="date" />
KiRa
  • 924
  • 3
  • 17
  • 42
  • @Holland. Like I said before. Try to create a new script then add the code and call the script in your main view. If you're ON now join chat again. – KiRa Jan 11 '17 at 00:57