KendoUI DateTimePicker在document.ready上未定义 [英] KendoUI DateTimePicker undefined on document.ready
本文介绍了KendoUI DateTimePicker在document.ready上未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在试图从document.ready()访问的mvc(asp.net)部分视图中具有Kendo DateTimePicker控件:
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并放弃了剃须刀版本:
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;
}
这篇关于KendoUI DateTimePicker在document.ready上未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文