jQuery datepicker在Modal MVC 3中不起作用

时间:2012-07-17 23:45:19

标签: c# asp.net-mvc-3 jquery-ui-datepicker

DatePicker适用于项目,但不适用于模式。模态是部分视图。

这是在编辑器模板中。

DateTime.cshtml

@model System.DateTime?
@Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue, new { @class = "editor-field" })

    <script type="text/javascript">
        if (typeof (jQuery) == 'function') {
            $(function () {
                if ($.datepicker) {
                    $('#@this.ViewData.TemplateInfo.GetFullHtmlFieldId("")')
                    .datepicker();
                }
            });
        }
    </script>

1 个答案:

答案 0 :(得分:0)

在编辑模板上试用此代码

@model System.DateTime?
@Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue, new { @class = "editor-field picker" })

并在共享视图上调用这样的脚本

    <script type="text/javascript">
        if (typeof (jQuery) == 'function') {
            $(function () {
                if ($.datepicker) {
                    $('input.picker')
                    .datepicker();
                }
            });
        }
    </script>