Holland
Holland

Reputation: 415

jQuery UI: tooltip works fine, but datepicker function not recognized

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.

Upvotes: 1

Views: 344

Answers (1)

KiRa
KiRa

Reputation: 924

You can use type = "date". Sample

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

Upvotes: 0

Related Questions