在 document.ready 上未定义 KendoUI DateTimePicker [英] KendoUI DateTimePicker undefined on document.ready

查看:26
本文介绍了在 document.ready 上未定义 KendoUI DateTimePicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 mvc (asp.net) 部分视图中有一个 Kendo DateTimePicker 控件,我试图从 document.ready() 访问它:

I have a Kendo DateTimePicker control in an mvc (asp.net) partial view that I am trying to access from document.ready():

@(Html.Kendo().DateTimePickerFor(vvm => vvm.StartTime)
                    .Name("dtpVisitStart")
                    .Format("yyyy/MM/dd HH:mm tt")
                    .TimeFormat("HH:mm:tt")
                    .Events(e => e.Change("dtpVisitStart_Change")
                                )                               
)

javascript:

The javascript:

$(document).ready(function () { 
    TestDTP();
});

function TestDTP() {
    var dtp = $("#dtpVisitStart").getKendoDateTimePicker();
    debugger;
}

调试器行运行时 dtp 未定义.加载局部视图时如何初始化此日期时间选择器?

When the debugger line runs dtp is undefined. How can I initialize this date time picker when the partial view loads?

推荐答案

我最终做的是从纯 javascript 初始化 datetimepicker 并放弃 razor 版本:

What I ended up doing is initializing the datetimepicker from pure javascript and ditched the razor version:

function TestDTP() {
    $("#dtpVisitStart").kendoDateTimePicker({
        format: "MM/dd/yyyy HH:mm tt",
        timeFormat: "HH:mm", 
        change: dtpVisitStart_Change, 
        value: "@(startTime)"
    });
    var dtp = $("#dtpVisitStart").getKendoDateTimePicker();
    debugger;
}

这篇关于在 document.ready 上未定义 KendoUI DateTimePicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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