我有一个显示一些 Ts 和 Cs 的 jQuery 对话框。它在禁用提交按钮的情况下呈现
用户应勾选复选框以确认他们已阅读它们以启用提交按钮。
这在 IE10、Chrome 和 Firefox 中运行良好。
但是,在 IE9 中,对话框在启用按钮的情况下呈现(尽管单击它不会触发提交)并且复选框不执行任何操作。
代码是:
<a href="#" id="open_terms" title="Terms">Terms and conditions</a>
<div id="terms" style="padding:12px">
<p>
On the day of the handover, a member of staff will take back your current laptop.
As such, it is your responsibility to ensure that you have backed up your data in advance of the handover,
ready to restore to your new laptop.
</p>
<p style="font-weight: bold">If your data is not backed up in advance, you may have to forfeit your booked slot and rebook the handover on another date.</p>
<input type="checkbox" id="cbTerms">Accept<br>
</div>
$(function () {
$('#open_terms').click(function(){
ShowDialog();
});
function ShowDialog() {
$('#cbEula').prop('checked', true);
$('#terms').css('visibility', 'block');
$('#terms').dialog({
modal: true,
width: '500px',
title: 'IMPORTANT! Remember To Backup Your Laptop',
open: function (event, ui) {
$('.ui-dialog-titlebar-close').hide();
$(this).parent().appendTo('form');
},
buttons: {
"Submit": function () {
$('form:first').submit();
}
}
});
var button = $(".ui-dialog-buttonpane button:contains('Submit')");
console.log(button);
$(button).button("disable");
};
$('#cbTerms').click(function () {
var button = $(".ui-dialog-buttonpane button:contains('Submit')");
console.log(button);
if ($(this).is(':checked')) {
$(button).button("enable");
$('#cbEula').prop('checked', true);
} else {
$(button).button("disable");
$('#cbEula').prop('checked', false);
}
});
});
JSFiddle在这里:http: //jsfiddle.net/bdgriffiths/wgJAE/