我需要手动调用.change()
来做一些操作,我已经写了一个.on()
其他input
控件的此功能。但是对于DatePicker
列,我需要手动触发它,因为每当日期设置为文本框时它都不会触发。
$('input.JDateCtrl').datepicker({
onSelect: function (dateText) {
debugger;
//$(this).parent().find('input[type=text]').val(dateText);
$(this).parent().find('input[type=text]').attr('value', dateText);
var ctrlID = $(this).parent().find('input[type=text]').attr('id');
$('#' + ctrlID).trigger('change');
// $('#' + ctrlID).change(); // Tried it too
}
});
.on()
如下。
$jQuery(document).on('change', '.JAsyncUpdateTxt', function () {
// Some Operations being performed in this block
});
但是每当我触发change
事件时,.on()
都不会触发。
附言:它已经包裹在$jQuery(document).ready();
里面
$(document).on('change', '.JAsyncUpdateTxt', function () {
// Some Operations being performed in this block
});
删除"jQuery"。使用任何一个。
请将您的 .on() 放在第一位,然后输入 .datepicker,如下所示:
$(document).on('change', '.JAsyncUpdateTxt', function () {
// Some Operations being performed in this block
});
$('input.JDateCtrl').datepicker({
onSelect: function (dateText) {
debugger;
//$(this).parent().find('input[type=text]').val(dateText);
$(this).parent().find('input[type=text]').attr('value', dateText);
var ctrlID = $(this).parent().find('input[type=text]').attr('id');
$('#' + ctrlID).trigger('change');
// $('#' + ctrlID).change(); // Tried it too
}
});
我认为这可以帮助你。
$(document).on('change', '.JAsyncUpdateTxt', function () {
// Some Operations being performed in this block
});
删除 jQuery 使用一个 jQuery 或 $