【问题标题】:jQuery datepicker doesn't work in Modal MVC 3jQuery datepicker 在 Modal MVC 3 中不起作用
【发布时间】:2012-07-17 23:45:19
【问题描述】:

DatePicker 围绕项目工作,但不能在模式中工作。 Modal 是一个局部视图。

这在编辑器模板中。

日期时间.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>

【问题讨论】:

  • 您可以尝试将自定义类添加到您的文本框并将脚本添加到实际的局部视图而不是编辑器模板上吗?您现在需要使用类而不是 id 调用 jquery 函数
  • @pollirrata 谢谢朋友,你能帮我写代码吗?

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


【解决方案1】:

在您的编辑器模板上尝试此代码

@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>

【讨论】:

  • 现在我得到了日历,但我不能点击 :(
猜你喜欢
  • 1970-01-01
  • 2020-03-30
  • 2015-12-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-21
  • 2021-09-24
  • 1970-01-01
相关资源
最近更新 更多