This is what is in my view:
@Html.TextBox("toDateFilter", "", new { @class = "datepicker" })
...etc
...etc
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script>
$(document).ready(function () {
$(".datepicker").datepicker();
});
</script>
I am getting the error:
Datepicker is not a function.
I have followed the advice of all the other similar questions, and nothing has worked. I also changed the View to these imports instead:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/ui-lightness/jquery-ui.min.css" />
I also tried this instead:
var $j = jQuery.noConflict();
$j("#datepicker").datepicker();
Also I did check that the jquery-ui.min.js file loaded correctly.
Any ideas why this is going wrong? Let me know if I can supply more info...
.ready()is running before the jquery-ui.min script has loaded. Can you put a breakpoint on that line and see if the external script has loaded at point?<head>and also maybe look into having the scripts load from your own domain, rather than CDN. It should then be safe to expect thatready()will run when all dependencies have loaded