简体   繁体   English

使用 jquery 日期选择器

[英]Using jquery datepicker

I have an @Html.edifor to show date of birth and I want to use jquery datepicker to show calendar.我有一个@Html.edifor 来显示出生日期,我想使用 jquery datepicker 来显示日历。 My scritp code is located in an external js file and proper reference to the file is on the view.我的 scritp 代码位于外部 js 文件中,并且对该文件的正确引用位于视图中。 I am also using bundle in app config.我也在应用程序配置中使用包。

here is my script这是我的脚本

$(function () {
    $("#DateOfBirth").datepicker({
        dateFormat: "dd-MMM-yy",
        changeMonth: true,
        changeYear: true
    });
});

I am getting the following error.我收到以下错误。

Jquery?v=gywVLk6VvVVR_J6-oRPIvBpBvXSXEW6ZffeMhgu--bE1:1 Uncaught TypeError: $(...).datepicker is not a function.

here is my bundleConfig这是我的 bundleConfig

        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
        "~/Scripts/jquery-ui-1.12.1.js"));
        //css  
        bundles.Add(new StyleBundle("~/Content/cssjqryUi").Include(
               "~/Content/jquery-ui.css"));

Can someone help me spot what is wrong.有人可以帮我找出问题所在。

Thank you!谢谢!

The function declaration and the Datapicker reference must be done before the JQuery Reference.函数声明和 Datapicker 引用必须在 JQuery 引用之前完成。

You must load jQuery or relative first.您必须首先加载 jQuery 或相关的。
Then Datapicker.然后是数据选择器。
Then the call to initialize the datapicker.然后调用初始化数据选择器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM