JQuery对话框(带按钮)在IE9中不起作用

时间:2013-07-08 15:36:13

标签: jquery internet-explorer-9

我有一个jQuery对话框,显示一些Ts和Cs。它通过禁用提交按钮呈现

用户应勾选一个复选框以确认已阅读它们以启用提交按钮。

这在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/

2 个答案:

答案 0 :(得分:2)

删除或注释掉您的console.log(button);语句。除非控制台处于打开状态,否则IE9会对它们造成阻塞。

答案 1 :(得分:1)

console.log在IE9,8和7中不起作用。

有理由请查看SO answer。如果您想在旧版本的IE中使用日志记录,我建议您log4javascript

工作fiddle已删除console.log。