这是代码
<td nowrap>
<input data-val="true" data-val-number="The field Id must be a number." data-val-required="The Id field is required." id="MeetingToEdit_Id" name="MeetingToEdit.Id" type="hidden" value="33" />
<input id="MeetingToEdit_SubjectId" name="MeetingToEdit.SubjectId" type="hidden" value="7f0912f9-4d7f-48a1-8290-acd66fd937f0" />
<input data-val="true" data-val-required="The FirstName field is required." id="MeetingToEdit_FirstName" name="MeetingToEdit.FirstName" type="hidden" value="R" />
<input data-val="true" data-val-required="The LastName field is required." id="MeetingToEdit_LastName" name="MeetingToEdit.LastName" type="hidden" value="Fa" />
<input data-val="true" data-val-required="The Email field is required." id="MeetingToEdit_Email" name="MeetingToEdit.Email" type="hidden" value="rukidmanff@msn.com" />
<input id="MeetingToEdit_Company" name="MeetingToEdit.Company" type="hidden" value="Australia" />
<input id="MeetingToEdit_HostFirstName" name="MeetingToEdit.HostFirstName" type="hidden" value="Neer" />
<input id="MeetingToEdit_HostLastName" name="MeetingToEdit.HostLastName" type="hidden" value="Admin" />
<input id="MeetingToEdit_HostEmail" name="MeetingToEdit.HostEmail" type="hidden" value="admin@admin.com" />
<input id="MeetingToEdit_HostMobile" name="MeetingToEdit.HostMobile" type="hidden" value="+6968723" />
<script>
$('#MeetingToEdit_StartTime').on('dp.change', function (selected) {
var endDate2 = $('#MeetingToEdit_EndTime');
endDate2.data("DateTimePicker").minDate(moment(selected.date));
endDate2.data("DateTimePicker").date(moment(selected.date).add(1, "hour"));
});
</script>
<input type="submit" class="btn btn-default" value="Update" />
<a class="btn btn-default" href="/Home/ReinviteVisitor?visitorId=7f0912f9-4d7f-48a1-8290-acd66fd937f0&email=rukiman%40msn.com">Cancel</a>
</td>
页面加载时出现此错误: Javascript运行时错误:无法获取未定义或空引用的属性'minDate'这是行:ndDate2.data(“DateTimePicker”)。minDate(moment(selected.date));
另外作为旁注,datetimepicker没有显示在正确的位置。由于表格中的行数越多,datetimerpicker的位置就越高,而不是作为打开文本字段的一部分出现。
答案 0 :(得分:0)
您的DateTimePicker实例似乎没有存储在输入的data属性中。
你应该尝试类似的东西:
var endDate2 = $('#MeetingToEdit_EndTime');
endDate2.minDate(moment(selected.date));
endDate2.date(moment(selected.date).add(1, "hour"));