【问题标题】:JQuery dialog (with button) not working in IE9JQuery 对话框(带按钮)在 IE9 中不起作用
【发布时间】:2013-07-06 00:26:57
【问题描述】:

我有一个显示一些 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/

【问题讨论】:

  • 你错过了在你的小提琴中添加 jQuery。

标签: jquery internet-explorer-9


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    请检查此SO answer。如果你想使用旧版IE登录,我建议你log4javascript

    Working fiddle 删除了 console.log。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-10
      • 2014-08-02
      • 1970-01-01
      相关资源
      最近更新 更多