我试图将编码值传递给datetimepicker,以便使用“ daysOfTheWeekDisabled”禁用特定的日期。问题是我收到TypeError:检查控制台时,g [b]未定义为错误。可能是什么问题?
代码如下:
<script type="text/javascript">
$(document).ready(function () {
$('#VehicleIDDD').change(function () {
var vehdrv = ($('#VehicleIDDD :selected').val());
var val = vehdrv.split("_");
var drvid = val[1];
var vehid = val[0];
if (drvid == "0") {
$("#DriverID > option").each(function () {
$(this).show();
});
}
else {
//console.log(vehid + "= with driver " + drvid);
$("#DriverID > option").each(function () {
var option_val = $(this).val();
if (option_val != drvid) {
$(this).hide();
}
});
}
$("#DriverID").val(drvid)
$("#VehicleID").val(vehid);
$.ajax({
type: 'GET',
url: '@Url.Action("checkCodingDay", "Reservation")',
data: { "VehicleID": vehid },
dataType: 'json',
success: function (data) {
var coding = data[0].CodingDay
daysOfWeekDisabled(coding);
},
error: function (emp) {
alert('error');
}
});
}).trigger("change");
})
function daysOfWeekDisabled(coding) {
$("#datetimepicker").datetimepicker({
daysOfWeekDisabled: coding,
});
$("#datetimepicker").datetimepicker('refresh');
}
</script>
如果您需要更多详细信息,请注释掉,我会添加您要查找的内容。