jQuery对话框(带有按钮)在IE9中不起作用 [英] JQuery dialog (with button) not working in IE9

查看:67
本文介绍了jQuery对话框(带有按钮)在IE9中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示一些T和C的jQuery对话框.在禁用提交按钮的情况下进行渲染

I have a jQuery dialog box showing some Ts and Cs. It renders with the submit button disabled

用户应选中一个复选框以确认他们已阅读它们,然后才能启用提交"按钮.

The user should tick a checkbox to confirm they have read them in order to enable the submit button.

这在IE10,Chrome和Firefox中正常运行.

This works fine in IE10, Chrome and Firefox.

但是,在IE9中,对话框在启用按钮的情况下进行渲染(尽管单击它不会触发提交),并且复选框不执行任何操作.

However, in IE9 the dialog renders with the button enabled (although clicking it does not trigger a submit) and the check box doesn't do anything.

代码是:

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

JSFiddle here: http://jsfiddle.net/bdgriffiths/wgJAE/

推荐答案

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

Remove or comment out your console.log(button); statements. IE9 chokes on them unless the console is open.

这篇关于jQuery对话框(带有按钮)在IE9中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆