I'm trying to activate the datapicker for a field but it's just not happening.
BundleConfig.cs:
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/moment.js",
"~/Scripts/bootstrap-datetimepicker.js",
"~/Scripts/respond.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/bootstrap-datetimepicker.css",
"~/Content/site.css"));
_Layout.html:
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
Created a datepickerready.js in the Scripts folder:
$(function () {
$('.datetimepicker').datepicker();
});
And finally the View in which I want the datepicker to be available:
<div class="form-group">
@Html.LabelFor(model => model.Achizitionare, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Achizitionare, new { htmlAttributes = new { @class = "form-control datetimepicker" } })
@Html.ValidationMessageFor(model => model.Achizitionare, "", new { @class = "text-danger" })
</div>
</div>
What am I doing wrong?
Found the solution: Forgot to call datepickerready.js