Johnny Grimes
Johnny Grimes

Reputation: 411

Bootstrap datetimepicker TypeError: $(...).datetimepicker is not a function

Hi I'm getting the below error when trying to apply the bootstrap datetimepicker to an input.

I've checked the source and I'm not referencing any of the JS libraries twice.

I've also tried shuffling the order of my references without any luck.

Does anyone know what I might be doing wrong?

I'm using: https://eonasdan.github.io/bootstrap-datetimepicker/

Error:

Uncaught TypeError: $(...).datetimepicker is not a function

Start of my _layout.chtml:

<script type="text/javascript" src="/Scripts/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
    <script type="text/javascript" src="/Scripts/moment.min.js"></script>
    <script type="text/javascript" src="/Scripts/bootstrap.min.js"></script>
    <script type="text/javascript" src="/Scripts/bootstrap-datetimepicker.min.js"></script>
    <link rel="stylesheet" href="/Content/bootstrap.min.css" />
    <link rel="stylesheet" href="/Content/bootstrap-datetimepicker.min.css" />

Body of my edit.chtml

 <div class="form-group">
            @Html.LabelFor(model => model.DateOfBirthDateTime, htmlAttributes: new { @class = "date-picker-standard control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.DateOfBirthDateTime, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.DateOfBirthDateTime, "", new { @class = "text-danger" })
            </div>
        </div>

Bottom of my edit.chtml

<script type="text/javascript">
    $(function () {


        $(document).ready(function () {
            $('.date-picker-standard').datetimepicker();
        });
    });
</script>

Upvotes: 1

Views: 2670

Answers (1)

Johnny Grimes
Johnny Grimes

Reputation: 411

Problem Solved:

This was hiding at the bottom of my _layout.chtml

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")

Upvotes: 1

Related Questions