我根据对Select字段的更改在jQuery对话框中启用了一个OK按钮 .
该部分有效,但是当我单击“确定”或“关闭”以保存该信息并继续时,会出现以下错误 .
Chrome:Uncaught TypeError:无法读取未定义Firefox的属性'apply':TypeError:d.click未定义... e =“button”>') . click(function(){d.click.apply(c.element) [0],参数)}).... jquery-ui.min.js(第14行,第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
1 回答
您需要将“确定”更改为“单击”按钮 .
jsfiddle