繁体   English   中英

jQuery datepicker在Asp.net MVC中处于部分视图时不起作用

[英]jquery datepicker is not working when it is in partial view in Asp.net MVC

我在局部视图中有文本框

 <input type="text" id="txtStartDate" />

我引用的脚本文件是

   <link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
   <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>

    $(document).ready(function () {
        $(document).on("focus", "#txtStartDate", function () {
            $(this).datepicker();
        });
    });

我已经在正常视图页面中尝试过它正在工作,但是当设置为部分视图时它不起作用,引用的jquery datepicker脚本是否存在此问题? 如果有任何解决方案,请帮助我。

在部分视图中呈现控件时,您可以编写

       <script>
            $(function () {
                $("#txtStartDate").datepicker();
            });
        </script>
<input type="text" id="txtStartDate" />

暂无
暂无

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

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