我正在根据选择字段的更改,在jQuery对话框中启用一个“确认”按钮。虽然这部分内容已经生效,但是当我点击“确认”或“关闭”以保存信息并继续时,会出现以下错误。
这是一个关于JSFiddle按钮错误的最简化演示:JSFiddle button error。
Chrome: Uncaught TypeError: Cannot read property 'apply' of undefined
Firefox: TypeError: d.click is undefined
... e="button">').click(function(){d.click.apply(c.element[0],arguments)})....
jquery-ui.min.js (line 14, col 5350)
var disposition; // I'm using this so that the alert('fixed') doesn't get call on load...
// Callback Disposition Dialog
$('#disposition_modal').dialog({
open: function () { // removed the default close link
$(this).parent().children(':first').children('a').remove();
},
buttons: [{
text: 'Cancel',
Ok: function () {
$(this).dialog("close");
}
}, {
text: 'OK',
disabled: true,
id: 'dm_btn',
Ok: function () {
if (disposition !== '' && undefined !== disposition) {
alert('fixed');
$(this).dialog("close");
}
}
}]
});
// toggle the OK button
$('#disposition_id_in2').change(function () {
disposition = $('#disposition_id_in2').val();
if ($('#disposition_id_in2').val()) {
$('#dm_btn').attr('disabled', false);
} else {
$('#dm_btn').attr('disabled', true);
}
});
这是一个关于JSFiddle按钮错误的最简化演示:JSFiddle button error。
jquery-migrate
库版本时,我遇到了相同的错误。从 WordPress 5.6 开始,他们增加了新的 jquery-migrate 版本。 - jave.web