My project is in .NET MVC 4 and I'm having trouble calling the datepicker. It is applied but the popup is small above the field and blank. I want to use it in this field:
@Html.TextBoxFor(model => model.DataDesligamento, new { @class = "form-control", @maxlength = 10, onkeydown = "formatar(this,'##/##/####',event)", onblur = "javascript:valida_data(this);" })
In the Layout called by View where the field I want the datepicker I make the following calls from the Bundles in the Head:
@Scripts.Render("~/bundles/ieLt9")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/maskedinput")
@Scripts.Render("~/bundles/datepicker")
@Scripts.Render("~/bundles/cpfl")
@RenderSection("scripts", required: false)
I think that's not it, because the datepicker is applied and if you open the console I can see that it has data in it, days, months, years, but not shown.
In the browser when you open the console, the following scripts are added:
<script src="/Scripts/modernizr-2.8.3.js"></script>
<script src="/Scripts/jquery-3.1.0.js"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.js"></script>
<script src="/Scripts/jquery.validate.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>
<script src="/Scripts/jquery-ui.min.js"></script>
<script src="/Scripts/jquery.maskedinput.js"></script>
<script src="/Scripts/bootstrap.js"></script>
<script src="/Scripts/bootstrap-datepicker.min.js"></script>
<script src="/Scripts/bootstrap-datetimepicker.js"></script>
<script src="/Scripts/bootstrap-datepicker.pt-BR.min.js"></script>
<script src="/Scripts/locales/bootstrap-datetimepicker.pt-BR.js"></script>
<script src="/Scripts/select.js"></script>
<script src="/Scripts/core.pp.js"></script>
<script src="/Scripts/core.init.pp.js"></script>
In the view, at the end of the file I add the datepicker in the field with the line:
aplicarDatePicker('DataDesligamento');
Here is the JavaScript function that applies datepicker:
function aplicarDatePicker(campo) {
$('#' + campo).datepicker({
format: 'dd/mm/yyyy',
language: 'pt-BR',
autoclose: true
});
}
Am I doing something wrong? Why does not the datepicker show the content in the popup?