错误“未捕获的TypeError:$(...)。datetimepicker不是函数” [英] Error "Uncaught TypeError: $(...).datetimepicker is not a function"

查看:170
本文介绍了错误“未捕获的TypeError:$(...)。datetimepicker不是函数”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试显示两个datetimepickers,但我收到错误Uncaught TypeError:$(...)。datetimepicker不是函数。
我安装了:



Install-Package Bootstrap.v3.Datetimepicker



Install-Package这是代码:

  @model MVCGreenhouseMonitoring.Models.Plotting.PlottingCalendarDropDownList 
< head>
< title>< / title>
< script src =〜/ Scripts / jquery-1.9.1.js>< / script>
< script src =〜/ Scripts / jquery-ui-1.11.4.min.js>< / script>
< script src =〜/ scripts / moment-with-locales.min.js>< / script>
< script src =〜/ scripts / bootstrap.min.js>< / script>
< script src =〜/ scripts / bootstrap-datetimepicker.js>< / script>
< link rel =stylesheethref =〜/ Content / bootstrap-datetimepicker.css/>

< / head>
< script>
$(function(){
$(#txtdatepicker1)。datetimepicker();
$(#txtdatepicker2)。datetimepicker();
});
< / script>

@using(Html.BeginForm(IntervalReports,Greenhouse,FormMethod.Post))
{
< table>
< tr>
< td>
< p>
开始日期:@ Html.TextBoxFor(m => m.StartDateCalendar,new {@id =txtdatepicker1,@ style =width:200px;})
< / p>
< / td>
< td>
< p>
结束日期:@ Html.TextBoxFor(m => m.EndDateCalendar,new {@id =txtdatepicker2,@ style =width:200px;})
< / p>
< / td>
< / tr>
< / table>
< input type =submitname =btnSubmitvalue =Submit/>
}

我在Scripts文件夹中有所有必需的脚本。

解决方案

只需将其包含在其他js文件之上:

 < script src =https://code.jquery.com/jquery-1.11.3.min.js>< / script> 

并像这样包装你的脚本:

  jQuery(document).ready(function($){
jQuery(#txtdatepicker1)。datetimepicker();
jQuery(#txtdatepicker2)。 datetimepicker();
});


I am trying to display two datetimepickers but i'm getting the error "Uncaught TypeError: $(...).datetimepicker is not a function" . I've installed :

Install-Package Bootstrap.v3.Datetimepicker

Install-Package Bootstrap.v3.Datetimepicker.CSS

Here is the code :

@model MVCGreenhouseMonitoring.Models.Plotting.PlottingCalendarDropDownList
<head>
    <title></title>
    <script src="~/Scripts/jquery-1.9.1.js"></script>
    <script src="~/Scripts/jquery-ui-1.11.4.min.js"></script>
    <script src="~/scripts/moment-with-locales.min.js"></script>
    <script src="~/scripts/bootstrap.min.js"></script>
    <script src="~/scripts/bootstrap-datetimepicker.js"></script>
    <link rel="stylesheet" href="~/Content/bootstrap-datetimepicker.css" />

</head>
<script>
    $(function () {
        $("#txtdatepicker1").datetimepicker();
        $("#txtdatepicker2").datetimepicker();
    });
</script>

@using (Html.BeginForm("IntervalReports", "Greenhouse", FormMethod.Post))
{
    <table>
        <tr>
            <td>
                <p>
                    Start Date: @Html.TextBoxFor(m => m.StartDateCalendar, new { @id = "txtdatepicker1", @style = "width:200px;" })
                </p>
            </td>
            <td>
                <p>
                    End Date: @Html.TextBoxFor(m => m.EndDateCalendar, new { @id = "txtdatepicker2", @style = "width:200px;" })
                </p>
            </td>
        </tr>
    </table>
    <input type="submit" name="btnSubmit" value="Submit" />
}

I have all the necessary scripts in the Scripts folder.

解决方案

Just include this on top of the other js files:

<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>

And wrap your script like this:

jQuery(document).ready(function($){
        jQuery("#txtdatepicker1").datetimepicker();
        jQuery("#txtdatepicker2").datetimepicker();
});

这篇关于错误“未捕获的TypeError:$(...)。datetimepicker不是函数”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆