无法在 MVC 5 Visual Studio 2015 中激活 bootstrap 日期选择器
Cannot activate bootstrap datapicker in MVC 5 Visual Studio 2015
我正在尝试为一个字段激活数据选择器,但它没有发生。
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)
在 Scripts 文件夹中创建了一个 datepickerready.js:
$(function () {
$('.datetimepicker').datepicker();
});
最后是我希望日期选择器可用的 View:
<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>
我做错了什么?
找到解决方案:忘记调用 datepickerready.js
我正在尝试为一个字段激活数据选择器,但它没有发生。
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)
在 Scripts 文件夹中创建了一个 datepickerready.js:
$(function () {
$('.datetimepicker').datepicker();
});
最后是我希望日期选择器可用的 View:
<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>
我做错了什么?
找到解决方案:忘记调用 datepickerready.js